9

I recently reinstalled node.js (latest version, 9.8.0) on my computer (running windows 10) as it started to glitch out.

The problem is, now npm doesn't work. For example, upon entering npm in cmd, I get the error:

Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Nodist'
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: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:170: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 process.emit (events.js:180:13)
    at process._fatalException (bootstrap_node.js:431:27)
Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Nodist'
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 Conf.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:234:20)
    at C:\Program Files\nodejs\node_modules\npm\lib\config\set-user.js:23: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:47:53
    at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
    at FSReqWrap.oncomplete (fs.js:170: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 process.emit (events.js:180:13)
    at process._fatalException (bootstrap_node.js:431:27)

The node command works fine, though. Why would this happen?

Edit: I have tried reverting to the recommended Node.js version (8.10.0), but I am getting the same issues.

0

3 Answers 3

14

I had a similar problem a while ago. Try navigating to the file named .npmrc, in C:\Users\%UserName%, and deleting it.

Sign up to request clarification or add additional context in comments.

2 Comments

That was it - Thanks!
in my case I actually had no .npmrc file, neither in my user directory and neither in app data's npm folder. This worked for me,
3

To fix this in Windows, create a directory junction to your users folder that didn't have a space in it. You can run a command like this in an administrative powershell:

cmd /c mklink /J "C:\Users\myname" "C:\Users\My Name"

You can then use this junction as if it were your real user directory:

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

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

(the above should update your user .npmrc file)

1 Comment

This is actually pretty smart, I didn't try this as I read this afterwards fixing my issue so for any future wanderers if above solution doesn't work for you this worked for me,
1

This maybe related to the NPM cache that needs to be cleaned you can do it using:

    npm cache clean

Let me know if it helped....

Comments