npx icon indicating copy to clipboard operation
npx copied to clipboard

npx returning Error: EPERM: operation not permitted on Windows, with spaces in path

Open jtsom opened this issue 6 years ago • 12 comments

As has been reported before, and (supposedly fixed), trying to run an npx command on Windows returns the above error. Full log below.

Info:

$ npm config list
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.4.1 node/v10.10.0 win32 x64"

; builtin config undefined
prefix = "C:\\Users\\John Tsombakos\\AppData\\Roaming\\npm"

; node bin location = C:\Program Files\nodejs\node.exe
; cwd = C:\Users\John Tsombakos
; HOME = C:\Users\John Tsombakos
; "npm config ls -l" to show all defaults.

node --version v10.10.0 npm -v 6.4.1 npx -v 6.4.1 (also fails with npx@latest)

Error log:

 npx webpack-bundle-analyzer .\dist\stats.json
Error: EPERM: operation not permitted, mkdir 'C:\Users\John'
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js:78:20
    at cb (C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\npm.js:228:22)
    at C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\npm.js:266:24
    at C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\config\core.js:83:7
    at Array.forEach (<anonymous>)
    at C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\config\core.js:82:13
    at f (C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\config\core.js:173:20)
    at C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\utils\error-handler.js:205
  if (npm.config.get('json')) {
                 ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (C:\Users\John Tsombakos\AppData\Roaming\npm\node_modules\npm\lib\utils\error-handler.js:205:18)
    at process.emit (events.js:182:13)
    at process._fatalException (internal/bootstrap/node.js:485:27)
Install for webpack-bundle-analyzer@latest failed with code 7

jtsom avatar Sep 20 '18 14:09 jtsom

This appears to be a duplicate of #100

paulcyr avatar Sep 27 '18 17:09 paulcyr

Any movement on this? The Duplicate #100 is still open. Can't use npx on Windows...

jtsom avatar Dec 03 '18 16:12 jtsom

I'm on Windows 10 Professional. I got the same issue and I got it fixed by running the following commands in command prompt.

npm install -g create-react-app
npx create-react-app

works

assadullahchaudhry avatar Jan 01 '19 00:01 assadullahchaudhry

I'm on Windows 10 Professional. I got the same issue and I got it fixed by running the following commands in command prompt.

npm install -g create-react-app
npx create-react-app

works

Thank you! This solved the problem for me.

anthonyaoun23 avatar Jan 10 '19 15:01 anthonyaoun23

I'm on Windows 10 Professional. I got the same issue and I got it fixed by running the following commands in command prompt.

npm install -g create-react-app
npx create-react-app

works

Thank you! This solved the problem for me.

You are welcome.

assadullahchaudhry avatar Jan 10 '19 15:01 assadullahchaudhry

Same problem here

silverqx avatar Feb 25 '19 13:02 silverqx

Doing an npm install -g create-react-app isn't really a solution per se, as the entire point of $ npx is to avoid the need for global installs. Modules like create-react-app change so frequently that they are typically out of date soon after installing them. So npx then allows you to execute a package without actually installing it, thereby ensuring that you are always using the latest cut of the module.

I had the same issue described above (EPERM) and the following thread - specifically the npm config set trick using ~1 - resolved the problem for me.

`


< hello >

    \   ^__^
     \  (oo)\_______
        (__)\       )\/\
            ||----w |
            ||     ||

`

drdanmorris avatar Mar 11 '19 01:03 drdanmorris

I had the same issue described above (EPERM) and the following thread - specifically the npm config set trick using ~1 - resolved the problem for me.

I didn't find that thread, ~1 solution will work, thx

silverqx avatar Mar 11 '19 07:03 silverqx

I just wanted to run: npx create-react-app react-tutorial I found it works after I use: npm install -g create-react-app

GOT THE FOLLOWING MESSAGE : Installing react, react-dom, and react-scripts...

KRISHANJIT avatar Mar 17 '19 12:03 KRISHANJIT

Thanks

emilyxiemao avatar Apr 09 '19 04:04 emilyxiemao

I'm on Windows 10 Professional. I got the same issue and I got it fixed by running the following commands in command prompt.

npm install -g create-react-app
npx create-react-app

works

Thank you! This solved the problem for me.

You are welcome.

doll612 avatar Apr 27 '19 18:04 doll612

Similar problem with some meaningful message.

PS C:\Users\Miix 320> npx create-react-app test-app
npm ERR! code ENOLOCAL
npm ERR! Could not install from "320\AppData\Roaming\npm-cache\_npx\3304" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Miix 320\AppData\Roaming\npm-cache\_logs\2019-05-11T06_30_56_843Z-debug.log
Install for create-react-app@latest failed with code 1

Look like there is problem somewhere in npx script with default path of npm-cache.

There is a npx's option --cache. So I create a folder c:\temp and successfully call npx with this option

md c:\temp npx --cache c:\temp create-react-app test-app

jojosati avatar May 11 '19 07:05 jojosati