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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With