Everything I do with NPM takes several minutes; especially npm install, even if I already have all the packages installed. I first thought the problem is that the old code I am working with just takes longer to update (because last time an older npm version was used) but the problem percists even if I repeat the process.
My system and other Information:
Windows 11 PC
Ubuntu 18.04.5 VM from the Microsoft Store
VS Code.
npm version 8.19.2
node version 16.17.0
From my package-lock.json file: "lockfileVersion": 2
I usally have 5 to 10 dependecies listed in my package file
My internet speed is around 25 MB/s
What I tried so far with no luck:
A newer Version of Ubuntu
Using http instead of https a la:
npm config set registry http://registry.npmjs.org/ --global
as was suggested in 'npm install' extremely slow on Windows.
It seems to me it still tries to connect to the https address (at least that's what it looks like if I use npm install --verbose to show more feedback).
Reinstalling Node and NPM through other means as it was suggested in Why is "npm install" really slow?
No matter what I still sit here, wasting ages waiting for my npm install.
I finaly found a solution. I just did not now to ask the right question.
The problem was that I was using WSL version 2 and my files are in C: and not the Ubuntu folders. A fix that worked for me was moving to WSL version 1.
More details can be found here.
If you're also switching to WSL version 1 and are having problems with node or npm, this might help.
Related
i am using mac book pro - M1 chip and bigsur
but I have a problem.
the speed so slow when i install any library to npm
please click the picture i have counted
the picture, i had install the 'react-native-fast-image'
but there consumes more 1000s for installed
likewise,
i had typed in terminal, 'npm i or yarn install'
Consumes more than 30 minutes.
for solving this, i have tried deleted xcode, and webstrom, and vsc
but, there are no change in speed.
I had this exact same issue. After speaking with Genius Bar we realised I was on an old version 12 of node. Node 15.5 onwards runs natively on M1 so isn't being parsed through Rosetta 2, which was likely causing the lag.
You can check the version of node you're on by running node -v
If you're on anything below 15, if you run nvm install v15 on terminal this might solve your issue by updating your node.
I had an error at this point (you might not) saying:
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Which was solved with this.
After sorting that, when running nvm install v15 it solved the lagginess :) good luck!
You might also find even after installing the latest node, your terminal defaults to an old version (mine did to much bemusement!)
You can solve it be setting a default, check this link.
In short, run:
nvm use node
This switches to the latest installed version of node.
Today I used for the first time Node/NPM 17 and I got back to these issues of NPM install taking forever.
I switched back to Node/NPM 14 and everything works again just fine.
For those who cannot move their project to node 15 overnight.
Install node by itself by going on nodejs.org reduce drastically npm library installation on mac book pro - M1 Pro Monterey.
When I try to create the starter React tutorial app using powershell, I get the below error:
"You are using npm 2.15.12 so the project will be boostrapped with an old unsupported version of tools".
"Please update to npm 3 or higher for a better, fully supported experience".
However, my NPM version is 6.11.3 as seen below.
What I have tried:
I have ran powershell as admin as answered in this question and restart.
I have also uninstalled and reinstalled Nodejs completely.
So after an extra hour digging around, I saw a few posts with similar (but not exactly) the same issue. I decided to install Yarn and install with that.
After install, I ran yarn cache clean and ran npx create-react-app your-app and it worked. Sorry for bothering you all.
I had the same problem. I'm running WSL with ubuntu, and yarn cache clear didn't work, but I noticed a node modules directory created in the project. I think it was messing with the node version so I deleted it. It worked
I have installed NodeJs 4.2.1 and Npm 2.14.7 successfully on Windows 10 x64, but when at the time of gathering dependencies on my new and clean system I'm having several errors. This is what I have done so far:
I have cloned many examples from take: github https://github.com/developit/express-es6-rest-api to name one, when I run npm install on it everything works fine, but when I run npm start it raises errors for missing packages for instance: babel-core/register, utf8, requests, etc. It seems that npm is not installing the 2nd dependency level way down. How can I fix this?, as I said before I've tried with several tutorials and even with something mine and everything is the same. I need a hand, noob on NodeJS here.
I have a Linux server that runs some virtual Machines using KVM. Host machine is a Debian derivate with kernel 2.6.32-32(-pve).
In roughly 75% of the times I run npm install, it hangs while installing modules. I ran it in silly debug level and it always hangs at the line
npm info postinstall [module name] (older npm versions)
or
npm verb unlock done using [...] (newer npm versions)
forever.
It happens in every project on the host machine and on the virtualized systems for every node and every npm version I have tested (a lot, including the newest ones (2.7.x atm)).
It also is not deterministic. Sometimes it works, sometimes not and most of the times it hangs on a different module.
On my dev machine (which is in the same network, running OS X 10.10) it works fine.
I am not behind any kind of proxy.
What could possibly be wrong here?
EDIT: For the time being I solved this problem by checking in all my dependencies as gzipped files using https://github.com/JamieMason/shrinkpack
I was having the same issue for several hours, and couldn't work out what the problem was. I tried re-installing everything a few times, manually installing individual modules, switching from x64 to x86 versions of NodeJS, etc, and got nowhere.
In the end, I changed networks, from WiFi over ADSL2+ [~2mbps] to 4G Hotspot [~20mbps] and it worked in 30 seconds. No idea why, since it didn't seem like a network speed issue, but it solved the problem.
Hope this helps someone else, too!
I had the same problem on our Jenkins slaves based on Ubuntu, and it was solved by upgrading npm.
Default npm installed by apt-get has version 1.3.10 now, which is very old (shown by npm --version). There are at least two ways to upgrade it:
Run sudo npm install -g npm command. If you want to install a specific version you can run append it at the end of command: sudo npm install -g npm#2.1.3.
Or you could add NodeSource repositories using these instructions and run usual sudo apt-get update.
I have the same problem on Windows. I deleted my npm-cache folder and reinstalled npm. Everything started working normally after that.
The npm-cache folder can be found at
<your-drive>\Users\<your-name>\AppData\Roaming\npm-cache
Remember to turn on 'View hidden files because the AppData folder by default is hidden
You can reinstall npm by using the command,
npm i npm -g
On Windows make sure you are in a native CMD (not in VSCODE or whatever IDE). Also, try increasing the max memory limit for node:
set NODE_OPTIONS=--max_old_space_size=8096
I did the same, switched my network from WiFi to 3G and it worked.
I'm experiencing the same problem, this is the issue on Github:
https://github.com/npm/npm/issues/7862
There are some useful tips that seemed to help a few people.
For me doing $ npm install -g node-gyp (as suggested here: http://gangmax.me/blog/2013/05/13/resolve-npm-update-node-gyp-hung-problem/) fixed the problem.
I had the same problem and just run
npm cache clean
And it works!
Had this same problem in Windows. The solution was to restart after installing node and npm and then run command prompt as administrator.
In my case, a system restart did the work.
I ran npm install --verbose which suggested some lock on a file in npm-cache. And I think the system released the file (which was under use) after the system restart. I am using windows.
Try cloning the project again and then run npm install to install the packages in your terminal.
I ran into this with npm v6, and it turned out I was just being impatient. I just needed to wait a little longer and it proceeded to the next step.
npm cache clean --force
works for me :)
=> this method working with me When npm block in installation Package for IONIC installation and ReactNative and another package npm.
you can change temporary :
npm config set prefix C:\Users[username]\AppData\Roaming\npm\node_modules2
change the Path in Environment Variables set C:\Users[username]\AppData\Roaming\npm\node_modules2
Run the your command to install your package .
open file explorer copy the link C:\Users[username]\AppData\Roaming\npm\node_modules
ok file yourpackage.CMD created another folder Created "node_modules2" in node_modules and contain your package folder.
copy your package file CMD to parent folder "npm"
copy your package folder to parent folder "node_modules"
now run npm config set prefix C:\Users[username]\AppData\Roaming\npm
change the Path in Environment Variables set C:\Users[username]\AppData\Roaming\npm
now package working correctly with Command line
Getting "npm: command not found" on this computer. Only way I knew to get it was by uninstalling node with Homebrew and reinstalling from the node.js site. Just reinstalled node.js on this computer and have npm version 2.5.1 with it.
I went to update to the newest (2.7.1) using:
sudo npm install npm -g
Updated without any errors, but running npm -v tells me I'm still on version 2.5.1
In the process of looking into the issue, see that old npm related files are on this computer. Old Changelog last modified 30 days ago exists saying "v2.7.1 (2015-03-05)" so npm was updated and on here at one point.
Can anyone point me in the right direction to figure out what is going wrong?
Making some assumptions here: there isn't anything really wrong, there just might be some installation issues. Homebrew should be just fine for installing node, Thoughtbot uses it to set-up laptops (see here).
To make sure Node/NPM installation is done in a smooth way, I did this:
sudo chown -R $USER /usr/local
Per this post.
I am on Yosemite and I haven't had any issues using this set-up, especially when updating NPM (did it when I read your question).