Skip to content
This repository has been archived by the owner on Apr 7, 2021. It is now read-only.

npx throwing Error : EPERM : operation not permitted with spaces in path : on windows #48

Open
rohitbakoliya opened this issue Mar 19, 2020 · 14 comments

Comments

@rohitbakoliya
Copy link

rohitbakoliya commented Mar 19, 2020

npx returns above Error while running npx create-react-app my-app

This error is due to spaces in username or in path
like : C:\Users\Rohit Bakoliya

node --version 
v12.16.1 (even with v13.11.0 and v10.16.3)
npm --version
16.13.4
npx --version
16.13.4

##Error Log

C:\Users\UserName>npx create-react-app practical-react
Error: EPERM: operation not permitted, mkdir 'C:\Users\UserName'
TypeError: Cannot read property 'loaded' of undefined
at exit (D:\Program Files D\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
at errorHandler (D:\Program Files D\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
at D:\Program Files D\nodejs\node_modules\npm\bin\npm-cli.js:77:20
at cb (D:\Program Files D\nodejs\node_modules\npm\lib\npm.js:225:22)
at D:\Program Files D\nodejs\node_modules\npm\lib\npm.js:263:24
at D:\Program Files D\nodejs\node_modules\npm\lib\config\core.js:83:7
at Array.forEach (<anonymous>)
at D:\Program Files D\nodejs\node_modules\npm\lib\config\core.js:82:13
at f (D:\Program Files D\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
at afterExtras (D:\Program Files D\nodejs\node_modules\npm\lib\config\core.js:173:20)
D:\Program Files D\nodejs\node_modules\npm\lib\utils\error-handler.js:98
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^

TypeError: Cannot read property 'loaded' of undefined
at exit (D:\Program Files D\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
at process.errorHandler (D:\Program Files D\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
at process.emit (events.js:198:13)
at process._fatalException (internal/bootstrap/node.js:496:27)
Install for create-react-app@latest failed with code 7

.npmrc contains wrong path
in my case : it is prefix=C:\Users\Rohit
I tried to change it to correct path.
but its not working.

@ic3man5
Copy link

ic3man5 commented Mar 29, 2020

Similar issue, My username is two words with a space, this seems to be a long standing issue.

PS C:\Users\David R\Documents\react_tutorial1> npx create-react-app my-app
Error: EPERM: operation not permitted, mkdir 'C:\Users\David'
TypeError: Cannot read property 'get' of undefined
    at errorMessage (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-message.js:38:39)
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:201:13)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:78:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:225:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:263:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (<anonymous>)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:80:13
    at f (C:\Program Files\nodejs\node_modules\npm\node_modules\once\once.js:25:25)
    at afterExtras (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:171:20)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97
  var doExit = npm.config.loaded ? npm.config.get('_exit') : true
                          ^

TypeError: Cannot read property 'loaded' of undefined
    at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:97:27)
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:216:3)
    at process.emit (events.js:311:20)
    at process._fatalException (internal/process/execution.js:164:25)
Install for [ 'create-react-app@latest' ] failed with code 7

Original Bug here: zkat/npx#100

Windows 10 1909
Node v12.16.1
npm 6.13.4
npx 6.13.4

@ic3man5
Copy link

ic3man5 commented Mar 29, 2020

Looks like the solution and pull request were done here: zkat/npx#181

@ic3man5
Copy link

ic3man5 commented Mar 29, 2020

I'm new to javascript / node / npm but looks like since the solution is already done I might be able to do the work to create a pull request to get this merged in. I don't really want to waste my time if its just going to end up like previous PR though. Please let me know if I can be of help here.

@ic3man5
Copy link

ic3man5 commented Mar 29, 2020

Work-around until this almost 3 year old bug is fixed:

Windows PowerShell with admin rights:

new-item -itemtype Junction -Path 'C:\Users\' -Name 'UserNameWithSpaces' -Target 'C:\Users\User Name With Spaces\'
npm config set cache C:\Users\UserNameWithSpaces\
npm config set prefix C:\Users\UserNameWithSpaces\

@ic3man5
Copy link

ic3man5 commented Mar 30, 2020

#14

@ConcurrentHashMap
Copy link

Workaround that worked for me: npm install -g create-react-app before.

@isekaimaou1109
Copy link

I have fixed this issue with the following steps:
-- step 1: open your git bash and run this command "npm install -g create-react-app" or "yarn global add create-react-app".

-- step 2: navigate to this directory "C:\Users{YOUR_USERNAME}\AppData\Roaming\npm" and open git bash.

-- step 3: re-run "npx create-react-app my-app".

*Note: Please step-by-step, NOT JUMP OR SKIP.

@rohitbakoliya
Copy link
Author

@SergioMorchon
Copy link

SergioMorchon commented May 21, 2020

@rohitbakoliya That's a workaround that requires extra software and steps, and the bug still persist.
I'd keep this issue open to give it visibility and hopefully reach a fix for it

EDIT
Related with #14 , so maybe duplicated?

@drebbe-intrepid
Copy link

Maintainer isn't going to do anything about it anyways:
#30 (comment)

@ljharb
Copy link

ljharb commented May 22, 2020

That's not what that comment says; it says they definitely are going to do something about it, later.

@rohitbakoliya rohitbakoliya reopened this May 22, 2020
@JustusW
Copy link

JustusW commented May 25, 2020

Workaround for this 3 year old bug:

cmd /c mklink /J "C:\Users\firstnamelastname" "C:\Users\Firstname Lastname\"

npm config set cache C:\Users\firstnamelastname\AppData\Roaming\npm-cache

npm config set prefix C:\Users\firstnamelastname\AppData\Roaming\npm

Original workaround from another git comment section. Shamelessly copied.

@mrinalpathak16
Copy link

This worked for me -
https://stackoverflow.com/a/46871748/12581294

@ariccio
Copy link

ariccio commented Nov 9, 2020

Related to: #6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants