This is my package.json
:
{
"name": "my-example-app",
"version": "0.1.0",
"dependencies": {
"request": "*",
"nano": "3.3.x",
"async": "~0.2"
}
}
Now, when I open the cmd and run npm install
, the install hangs. What am I doing wrong?
I had the same problem. The reason - wrong proxy was configured and because of that npm was unable to download packages.
So your best bet is to the see the output of
$ npm install --verbose
and identify the problem. If you have never configured proxy, then possible causes can be
npm install --verbose
, deleting the file at latest log path shown before a hang up. Finally installation came up to the end.
npm install --versbose
(following your advice) and then reran the webpack install. All is well!
Commented
Dec 19, 2018 at 18:06
yarn
globally using npm
then running yarn install
fixed this for me (also yarn
logs "There appears to be trouble with your network connection. Retrying...
" but at least it does not hang and continues till Done in 1035s.
is logged).
Commented
Dec 8, 2020 at 6:20
You can try deleting package-lock.json
and running npm install
afterwards.
This worked for me.
npm install
would get stuck on the same package every time (on both machines even). I removed the package-lock.json
as well as the node_modules
directory (just to be sure) and finally it worked :)
I was having the same problem. I tried a
npm config set registry http://registry.npmjs.org/
to turn off https. I also tried
npm set progress=false
to turn off the progress bar (it has been reported to slow down downloads).
The problem was with my network driver. I just needed to reboot and the lag went away.
--verbose
told me mine was failing at npm http fetch 200 https://registry.npmjs.org/some-project/-/some-project-X.X.X.tgz
Commented
Sep 27, 2016 at 20:24
Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher
On MacOS, I was able to solve this by
networksetup -setv6off Wi-Fi
After installing, you can revert to the original configuration with
networksetup -setv6automatic Wi-Fi
npm i
it was getting stuck in random dependencies. This actually works for me, do you know why this fixes the problem?
I had the same issue on macOS, after some time struggling and searching around, this answer actually solved the issue for me:
npm config rm proxy
npm config rm https-proxy
npm config set registry http://registry.npmjs.org/
http
instead of https
- > Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1
Commented
Nov 28, 2022 at 15:06
npm cache clear --force
has fixed this issue for me in the past.
Furthermore, when running npm install
on an air-gapped network (by the way, I provide a description about how to do this with Verdaccio), I had an issue where the install would hang at the very end. Turning off auditing (i.e. npm set audit false
) on the machine on the air-gapped network resolved this issue.
Updating npm
helped me on Mac OS. Use the command:
sudo npm install -g npm@latest
sudo
(elevated user privileges). Make sure this is required for your system before running this.
I am behind a corporate proxy, so I usually use an intermediate proxy to enable NTLM authentication.
I had hangs problem with npm install when using CNTLM proxy. With NTLM-APS (a similar proxy) the hangs were gone.
It was strange but I guess I was just being impatient ran -> npm install --verbose and saw there was progress but it was just really slow!!! All I needed was patience :D
Remove node_modules & package-lock.json from previous npm install and install again
rm -rf node_modules package-lock.json
npm install
or
If npm install loader is stuck and then pops up with..
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! errno UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! request to https://registry.npmjs.org/jest failed, reason: unable to get local issuer certificate"
then,
npm config set strict-ssl false
npm install
or
Follow to uninstall Node.js and install properly
https://www.geeksforgeeks.org/how-to-completely-remove-node-js-from-windows/
https://coding-boot-camp.github.io/full-stack/nodejs/how-to-install-nodejs
I personally had this issue and did all the steps I listed above. My issue was fixed with npm config set strict-ssl false
Surprisingly just restarting my computer and running npm install
again worked for me
When your ssh key is password protected run ssh-add
. npm probably hangs somewhere asking for your password.
Incase its useful to others, the following is what worked for me:
On my machine, although npm proxy was set correctly, npm install
waits forever doing something like sill extract. Re-trying npm install
waits forever on the same package again and again.
After waiting for a long timeout, npm install
printed an error message implying that git was trying to fetch something.
The problem vanished after configuring git proxy using the below command:
git config --global http.proxy https://proxy-server:port
Note the https
in the value of http.proxy
without which the configuration did not take effect. Proxy server settings (http / https / port) might vary for users; hence its worth spending a bit of time experimenting with npm and git proxy server settings.
The registry(https://registry.npmjs.org/cordova) was blocked by our firewall. Unblocking it fixed the issue.
With due respect to all the answers, I switched to a different network and it worked for me.
On windows i suddenly had the same issue and tried all of the above, but the final solution for me was to switch off the ransomware protection which I had activated. It somehow doesn´t go well along with npm
I've hit this problem a couple times.
npm install
worked.npm install
worked.For me it was Nord VPN client that caused the issue. Even though the vpn client wasn't connected it had for some reason got itself in a twist.
Restarting the Nord VPN Windows services didn't work, only a full reboot :-(
What prompted me to look at this was
Inter
from Google Fonts. Using fallback font instead.This method is working for me when npm blocks 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 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 the package is working correctly with the command line.
I'm not sure if your problem is being caused by the same reason that mine was, but I too was experiencing a hanging "npm install" and was able to fix it.
In my case, I wanted to install typescript locally in the project:
npm i typescript --save-dev
For some reason this was conflicting with a global install of typescript that I had, and the shell was just hanging forever instead of finishing or erroring...
I fixing it by first removing the globally installed typescript with the -g global flag:
npm uninstall typescript -g
After doing this the first command worked! 👍
install nvm (Node Version Manager) and downgrade node version from 14 to 12 solved the issue in my case
In my case npm install
was hanging because it was waiting for me to input a password to my ssh key while cloning from git repository. There was no prompt and I realized this might be the case when I typed random character and nothing was echoed back. In my case I had to look at package.json
file and clone locally repositories listed there. Then I updated package.json
and changed paths of those git repositories to my local paths. After doing this everything else was installed without further errors.
I had npm hanging on installation of electronjs on Windows 10. I reinstalled and still it was hanging. But I noticed it got installed on another desktop in the same network. So finally I found the culprit. The issue was caused by Bitdefender free edition. There was no warning by the antivirus but it was blocking it silently. Even the console was not closing once the installation starts as it kept hanging. Disable antivirus/firewall if its on Windows and make sure network is open as npm does not seem to have a proper way of communicating network blocks and will keep proceeding indefinitely.
I tried almost every method described in the answers, they didn't work for me. Initially I was using the integrated terminal inside VSCode. I ran the same command in the native terminal instead, and it worked!
Hope this will help someone
For anyone on MacOS (I'm on Mojave 10.14), the following helped me out: https://github.com/reactioncommerce/reaction/issues/1938#issuecomment-284207213
You'd run these commands
echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
sudo sysctl -w kern.maxfiles=65536
sudo sysctl -w kern.maxfilesperproc=65536
ulimit -n 65536
Then try npm install
once more.
check your environment variables for http and https
The existing entries might be creating some issues. Try deleting those entries.
Run "npm install" again.
I just turn off my windows firewall and it worked for me. You can also try different versions of npm.
Check your .npmrc
file for a registry
entry (which identifies a server acting as a package cache.)
For me, npm install
would hang partway through, and it was because of a old / non-responsive server listed in my .npmrc
file. Remove the line or comment it out:
>cat ~/.npmrc
#registry=http://oldserver:4873
(And/or check with your IT / project lead as to why it's not working ;)
npm install
.npm install --verbose
and see if you can find anything.