Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm hangs on any command

I installed last version of Node.js (12.2 x64 windows) After I run cmd as administrator and try to call any npm command (except npm -v), cmd window is hanging. After Ctrl+C it returns

Terminate batch job (Y/N)?

enter image description here

I was trying to left cmd for several hours but it didn't give some results. It is strange because node.exe process is consuming CPU and memory quite hard.

I was trying to reinstall node.js several times without success.
I can't even get some debug information.

I faced such issue on my VM which I was using by connecting via rdp. Same version installed on my laptop works ok. On my VM I had Kaspersky antivirus, but after switching it off I got same result.

Did somebody face such issue? Is there some way to get more information problem? Could you please recommend me some way to resolve?

like image 296
Alex Kapelyukhovskiy Avatar asked Apr 01 '15 10:04

Alex Kapelyukhovskiy


People also ask

What to do when npm I is stuck?

Remove node_modules and package-lock. To solve the issue, try removing the entire node_modules/ folder and the package-lock. json file. Then try running the npm install command again. That may fix the issue.

Why npm command is not working?

The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.

How do I force npm to run?

Run npm update -g npm. Execute this command by running the command prompt as Administrator npm install -g windows-build-tools. Run npm install inside the project folder where the package. json file is located, if it doesn't work run: npm install --force.


2 Answers

I've finally resolved my issue. According to suggestion from our local read me file

Node.js (with NPM) Note: On windows server machines, instead of node modules been installed at user %APPDATA% path, its better to install at a global path e.g c:\npm. This could be acheived by the npm command: $ npm config set prefix 'c:\npm' This is not required on individual developer's machine.

I've executed npm config set prefix 'c:\npm'.

As result it added prefix="'c:\\npm'" to my .npmrc file

This make node.js really crazy. It takes me about an hour to debug all these js scripts npm.js code.js etc... to find that it calls mkdirp with 'c:\\npm'\etc and it loop process forever.

like image 174
Alex Kapelyukhovskiy Avatar answered Oct 21 '22 08:10

Alex Kapelyukhovskiy


If anyone will encounter this problem in the future you need to find the npmrc file delete it and delete all configurations for node, delete node as well and install it, this should fix that. when deleting node some of the configurations aren't deleted so you have to delete it manually.

like image 42
illya yurkevich Avatar answered Oct 21 '22 07:10

illya yurkevich