npx icon indicating copy to clipboard operation
npx copied to clipboard

Error: EPERM: operation not permitted, mkdir 'C:\Users\Foo'

Open AvailCat opened this issue 7 years ago • 93 comments

Environment: Windows 10 npx Version: 9.4.1 See also: #84

Reason: My user home directory contain whitespace, like foo bar

AvailCat avatar Jul 21 '17 18:07 AvailCat

@Meeeeow could you post the actual terminal output for this, please? I'm not exactly sure which place it's coming from with just this info.

zkat avatar Jul 22 '17 02:07 zkat

Error: EPERM: operation not permitted, mkdir 'C:\Users\Foo'
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:213:17)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:215:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:253:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (native)
    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:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:213
  if (npm.config.get('json')) {
                ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:213:17)
    at emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
    at process._fatalException (bootstrap_node.js:329:26)
Install for prefix@latest failed with code 7
Error: EPERM: operation not permitted, mkdir 'C:\Users\Foo'
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:213:17)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:215:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:253:24
    at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7
    at Array.forEach (native)
    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:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:213
  if (npm.config.get('json')) {
                ^

TypeError: Cannot read property 'get' of undefined
    at process.errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:213:17)
    at emitOne (events.js:115:13)
    at process.emit (events.js:210:7)
    at process._fatalException (bootstrap_node.js:329:26)
Install for cowsay@latest failed with code 7

@zkat

AvailCat avatar Jul 22 '17 09:07 AvailCat

Thanks! This looks like a bug in npm itself. I'll look into it!

zkat avatar Jul 22 '17 17:07 zkat

I had the similar issue. Got fixed just by cleaning the npm cache.

npm cache clean

frenmanoj avatar Sep 26 '17 20:09 frenmanoj

Error: EPERM: operation not permitted, mkdir 'C:\Program Files\Java\JDK.ioni at Error (native) at Object.fs.mkdirSync (fs.js:924:18) at new IonicStore (D:\ConCustomer\node_modules\ionic\lib\ionic\store.js:2 ) at Object. (D:\ConCustomer\node_modules\ionic\lib\cli.js:6:19) at Module._compile (module.js:570:32) at Object.Module._extensions..js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17)

prat1477 avatar Oct 16 '17 06:10 prat1477

can anyone tell me how to fix this ????

prat1477 avatar Oct 16 '17 06:10 prat1477

npm clean cache doesn't work. No NPM commands work. They are all result in this same error. Even npm -v

jrmcdona avatar Nov 11 '17 02:11 jrmcdona

running cmd through administrator works for me

patnaix avatar Nov 14 '17 15:11 patnaix

I noticed that the path in the error message cut off prior to the first space. The path to my user folder is 'C:\Users\Paul Cyr'.

Environment: Windows 10 Build 15063.726

Error: EPERM: operation not permitted, mkdir 'C:\Users\Paul'
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:214:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:252: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:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\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:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:374:26)
Install for prefix@latest failed with code 7
Error: EPERM: operation not permitted, mkdir 'C:\Users\Paul'
TypeError: Cannot read property 'get' of undefined
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:214:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:252: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:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
C:\Program Files\nodejs\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:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:374:26)
Install for webpack@latest failed with code 7

paulcyr avatar Dec 11 '17 19:12 paulcyr

Changing the command from webpack --config webpack.config.js to node_modules\.bin\webpack --config webpack.config.js solved my problem.

paulcyr avatar Dec 11 '17 19:12 paulcyr

I have the same problem but I have only encountered it with 2 modules so far. NVM for windows and TSlint.

OS: Windows 10 NPM: 5.6.0

Tokimon avatar Dec 13 '17 00:12 Tokimon

I was hit with the same problem, same backtrace, and for the same reason as the OP . NPM: 5.6.0 Node: 9.2.0 OS: Windows 10 version 1709 (Fall Creators Update)

wolfy1339 avatar Dec 15 '17 04:12 wolfy1339

Any update on when the fix for this will be included? It is popping up through more and more modules

ghost avatar Jan 10 '18 21:01 ghost

I also have this issue, although it is failing on mkdir of a username with a space in it, that is not on my computer. Is this a config setting I should change (maybe it somehow mixed up user config that I had on an old computer)?

Fixed Did a search for .npmrc file, and changed prefix= to the correct user.

JordanJD avatar Jan 26 '18 15:01 JordanJD

I think you should excute this command on administrator "npm config set prefix path/to/Actual_npm_folder"

DninoAdnane avatar Mar 07 '18 19:03 DninoAdnane

any news if there ways to resolved the issue regarding user profile paths with spaces.

nullstrike avatar Mar 26 '18 15:03 nullstrike

i m also facing same problem Error: EPERM: operation not permitted, mkdir 'C:\Users\user' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:224:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:262:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7 at Array.forEach () 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:178:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:35:29 at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:35:29 at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:35:29 at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 at FSReqWrap.oncomplete (fs.js:152:21) C:\Program Files\nodejs\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:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at emitOne (events.js:116:13) at process.emit (events.js:211:7) at process._fatalException (bootstrap_node.js:375:26) Error: EPERM: operation not permitted, mkdir 'C:\Users\user' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:224:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:262:24 at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:81:7 at Array.forEach () 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:178:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:35:29 at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:35:29 at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:35:29 at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 at FSReqWrap.oncomplete (fs.js:152:21) C:\Program Files\nodejs\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:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at emitOne (events.js:116:13) at process.emit (events.js:211:7) at process._fatalException (bootstrap_node.js:375:26)

not any single npm command work

chetanbajaj avatar Mar 29 '18 10:03 chetanbajaj

I'm still having the problem. Now with TypeScript as well. Exactly the same error as the ones above.

Tokimon avatar Apr 09 '18 08:04 Tokimon

Jumping in.. Same issue here

Error: EISDIR: illegal operation on a directory, read TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:224:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:262: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 finalize (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:194:14) at Conf.afterCARead (C:\Program Files\nodejs\node_modules\npm\lib\config\load-cafile.js:14:14) at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16 at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:495:12)

eyalewin-zz avatar Apr 17 '18 14:04 eyalewin-zz

Seeing the same behavior here with respect to paths with spaces. Appears to be limited to npx. npm cache verify has no effect.

Output as follows for directory C:\Users\Foo G. Bar

Error: EPERM: operation not permitted, mkdir 'C:\Users\Foo' TypeError: Cannot read property 'get' of undefined at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20 at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:224:22) at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:262: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:178:20) at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53 at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29 at FSReqWrap.oncomplete (fs.js:152:21)

ajsaulsberry avatar Apr 23 '18 17:04 ajsaulsberry

Am I reading this right, that there's a fix (#138) but until it gets merged, npx doesn't work on Windows (if my profile dir has a space in it)? Bummer, I just found out about npx today and got all excited to stop typing ./node_modules/.bin so much...

thw0rted avatar Apr 24 '18 13:04 thw0rted

I have the same issue, but I'm on a Mac and I have no spaces in my home directory. Node is installed in /usr/local/....

Note that this problem goes away if I install using sudo

NPM Version 5.6 Tried on Nodes version 8.11 and 10.0

abd3 avatar Apr 26 '18 22:04 abd3

Hi I got the same issue following solved mine npm install -g create-react-app then npm create-react-app (your-app-name)

falakejaz avatar May 03 '18 19:05 falakejaz

@falakejaz Do you mean npx create-react-app? npm create-react-app won't work

legodude17 avatar May 03 '18 19:05 legodude17

I have similar issue, however it is only happening when I try to run my website in IIS (10.0) Operating System: Windows 10 (10.0.15063) Running through Visual Studio 2017 Enterprise (15.6.7). And here is the stack trace:

    Microsoft.AspNetCore.SpaServices:Error:     
    at errorHandler (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:83:20
    at cb (C:\Program Files\nodejs\node_modules\npm\lib\npm.js:214:22)
    at C:\Program Files\nodejs\node_modules\npm\lib\npm.js:252: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:178:20)
    at C:\Program Files\nodejs\node_modules\npm\node_modules\mkdirp\index.js:47:53
    C:\Program Files\nodejs\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:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:205:18)
    at emitOne (events.js:116:13)
    at process.emit (events.js:211:7)
    at process._fatalException (bootstrap_node.js:374:26)
    Error: EPERM: operation not permitted, mkdir 
    'C:\Windows\system32\config\systemprofile\AppData\Roaming\npm'  
  
I am not sure if this will affect this issue but I am using Angular (5.2.8) with .NET Core 2.0 website.
It works fine for IIS Express but as soon as I try to use it with IIS it fails.  

Kind Regards Lukasz

jaworekplay avatar May 04 '18 15:05 jaworekplay

I think it is related to being admin, some how. For instance I just tried to install and if you check Building section it says;

//if use Windows:
npm config set prefix "C:/Program Files/nodejs/npm_global"
npm config set cache "C:/Program Files/nodejs/npm_cache"

I could set prefix but when I entered cache it gave the the typical error which everyone had above. But when @patnaix said "running cmd through administrator works for me" , I opened Powershell as administrator and runned npc cache clean first. Then ran the commands above and done it without getting any error.

I hope it helps.

legendarynacar avatar May 08 '18 20:05 legendarynacar

Removing npmrc worked for me

ghost avatar May 29 '18 14:05 ghost

@Sampana worked for me as well.

jraack avatar May 29 '18 21:05 jraack

@legendarynacar I tried changing npm cache location, no error, but still does not for (the npx)

@Sampana removing npmrc doesnt seem to work too

mcb345 avatar Jun 05 '18 16:06 mcb345

find the NPMRC file located in C:\Users\ . oped this file in text editor and remove what ever is written there like "prefix=C:/Program Files/nodejs/npm_global" and save again . now run NPM command it will work :)

1kewin1 avatar Jun 09 '18 19:06 1kewin1