Problem with npm after reinstalling node.js

I recently reinstalled node.js (latest version, 9.8.0) on my computer (running Windows 10) when it started crashing.

The problem is that npm is not working now. For example, when entering npm in cmd, I get an 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 just fine. Why is this going to happen?

Edit: I tried to revert to the recommended version of node.js (8.10.0), but I am having the same problems.

+6
source share
3 answers

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

+5
source

Perhaps this is due to the NPM cache that needs to be cleared, you can do this using:

  npm cache clean 

Let me know if this helped ...

+1
source

To fix this on Windows, create a directory intersection with a user folder that did not have a space. You can run this command in administrative PowerShell:

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

Then you can use this transition 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 

(above should update your custom .npmrc file)

0
source

Source: https://habr.com/ru/post/1275911/


All Articles