NPM install hangs on loadRequestedDeps

2020-04-08 13:19发布

问题:

When I download any package using NPM, it hangs on the last command "loadRequestedDeps." I've added my whole -verbose output to the end of this question for reference. It will just sit there until I cancel the command, and nothing will be installed and my package.json will not be updated.

What could the issue be? I've looked around but haven't found out how to fix my particular problem.

Here's some info:

  • OS is Windows 10
  • Node version is 6.9.1
  • NPM version is 3.10.8
  • My CPU maxes out at 100% whenever I run NPM install. Could that be the issue itself? I used to be able to use NPM install on this computer, however.

Thanks for anyone who can help. The verbose output is below.

npm info it worked if it ends with ok
npm info using npm@3.10.8
npm info using node@v6.9.1
npm info ok
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'install',
npm verb cli   'moment',
npm verb cli   '--save',
npm verb cli   '-verbose' ]
npm info using npm@3.10.8
npm info using node@v6.9.1
npm verb request uri https://registry.npmjs.org/moment
npm verb request no auth needed
npm info attempt registry request try #1 at 11:19:11 AM
npm verb request id 6aa9ece5a04fcd33
npm verb etag W/"583b0871-194b0"
npm verb lastModified Sun, 27 Nov 2016 16:23:13 GMT
npm http request GET https://registry.npmjs.org/moment
npm http 304 https://registry.npmjs.org/moment
npm verb headers { date: 'Tue, 29 Nov 2016 19:19:02 GMT',
npm verb headers   via: '1.1 varnish',
npm verb headers   'cache-control': 'max-age=300',
npm verb headers   etag: 'W/"583b0871-194b0"',
npm verb headers   age: '11',
npm verb headers   connection: 'keep-alive',
npm verb headers   'x-served-by': 'cache-sjc3136-SJC',
npm verb headers   'x-cache': 'HIT',
npm verb headers   'x-cache-hits': '1',
npm verb headers   'x-timer': 'S1480447142.653125,VS0,VE0',
npm verb headers   vary: 'Accept-Encoding' }
npm verb etag https://registry.npmjs.org/moment from cache
npm verb get saving moment to C:\Users\Zach\AppData\Roaming\npm-cache\registry.npmjs.org\moment\.cache.json
npm verb correctMkdir C:\Users\Zach\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
npm verb cache add spec moment
npm verb addNamed "latest" is being treated as a dist-tag for moment
npm info addNameTag [ 'moment', 'latest' ]
npm verb addNameTag registry:https://registry.npmjs.org/moment not in flight; fetching
npm verb get https://registry.npmjs.org/moment not expired, no request
npm verb addNamed "2.17.0" is a plain semver version for moment
npm verb addRemoteTarball https://registry.npmjs.org/moment/-/moment-2.17.0.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/moment/-/moment-2.17.0.tgz',
npm verb addRemoteTarball   'a4c292e02aac5ddefb29a6eed24f51938dd3b74f' ]
[    ..............] \ loadRequestedDeps: verb addRemoteTarball [ 'https://registry.npmjs.org/moment/-/moment-2.17.0.tgz',

回答1:

I had this exact same issue, and it drove me crazy for about a day before I found these solutions.

After creating a new "tmp" folder in my C drive, and then changing the TEMP variable in my SYSTEM Environment variables to C:\tmp. My "npm install" was still not working. (This action was based on Zach Nagatani's answer.)

I also had two TEMP variables defined in my USER Environment variables, and I had to delete one of the variables for my "npm install" to start working.

The above action was based on this post: https://github.com/npm/npm/issues/7590

I was so glad when I found it. Many thanks to you all.



回答2:

Create new folder tmp in C: drive and go to the command prompt and type:

npm config set tmp C:/tmp



回答3:

this is very general error .. you have to debug with

npm install -verbose

it maybe 1) locked package.json 2) you are in private network and can't access outside world for some reason 3) cache is not good ( you may try with npm clear cache ) or ( cache verify ) or even changing its path (npm config set tmp )



回答4:

npm cache verify did the trick for me!

EDIT

npm was stuck on loadAllDepsIntoIdealTree.

I couldn't figure out the issue, so it got me here. I saw @franckstifler's answer about npm cache clear and tried that, but the command was deprecated.

The shell itself instead suggested using npm cache verify. I did that and it worked! The garbage data in cache got swiped away and I rerun npm i --save-dev on my working folder and it worked.



回答5:

Sometimes when you have tried several times to install a package, you need to clear your cache: npm cache clear. But yarn is a really better option compared to npm, it is fast and reliable. Install it with npm -i -g yarn and to download dependencies yarn add package_name from a package.json you use yarn install.



回答6:

So, after trying to clear the npm cache, update my npm and node version, reinstalling npm and node, etc... I found that changing my Environment Variable TEMP to = C:\tmp worked. I'm not sure why. Any info would be nice.

I found the answer from this thread: npm install hangs on windows with multiple temp directories set

NOTE: I could use the method he uses (using the set command on my directory, but I had to do this with every new project. Changing the variable via System, Advanced System Settings, Environment Variables changed it globablly, so now I'm all good to go.



回答7:

i tried googling nothing worked for me finally i found the fix by setting the environment varible

try use https://github.com/npm/npm/issues/10462



回答8:

Finally Resolved The Problem(Wondering)

Change Both System And User TEMP Variable point to C:\temp and make a directory as C:\temp.

1.TEMP=C:\temp;

2.Make A Directory temp at C:\