Npm installing module keep timing out - node.js

The current problem is that I am unable to install any npm modules as it always time out before installing. I tried using npm cache-clean and npm doctor but all are in green. Checking on the ping is 105. The npm server are all working green so there shouldn't be any error in downloading npm modules.

To get rid of the error,
Start command prompt and enter the code below in command prompt. After restarting the computer, you should be able to download npm.
netsh int ip reset resetlog.txt
When you run the reset command, it rewrites two registry keys that are used by TCP/IP. This has the same result as removing and reinstalling the protocol.

Related

"npm install" hangs on sill: idealTree build

I've been trying to solve this over the last two days, or so, with no effect:
Solution that I have attempted include:
Deleting the package-lock.json file
Coordinating with the other dev on the project to align the Node.js
version and reinstalling the whole framework
Using --verbose as part of the "ndm i" command
Editing environmental variables to add NPM to them
Deleting the "node_modules" folder
Disabling, then re-enabling SSH
Trying with and without VPN being active
Clearing the cache via the command line, i.e. the node_modules step
above
This is a link to another topic on the same issue on SO that also seems to be outstanding: Link
I've reviewed the range of discussions on SO about the problem, to no particular avail, and I think I'm out of options. Any insight is appreciated
On MacOS (M1 chip) switching the IPV6 from Automatically to Link-local only fixed a very similar issue. When I tried adding registry.npmjs.org, npm was similarly getting "stuck".
To apply this setting go to System Preferences >> Network >> press Advanced >> TCP/IP tab >> on Configure IPv6 select Link-local only and apply
I found this solution in this thread
The issue was the connection to registry.npmjs.org, after the installation attempt finally processed.
The solution is that when you go to run "npm install", you have to add "registry.npmjs.org" at the end of it, and it sums up to:
npm i registry.npmjs.org
Make sure to run this from the folder of your NodeJS project.
Other useful links to consult:
NPM stuck on idealTree: timing idealTree
npm install hangs
stop "npm install" at [..................] | idealTree:regal: sill idealTree buildDeps
Error : getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443 --this one is for Angular, but still relevant.
As a final curiosity, going to registry.npmjs.org leads to this site:
where as https://www.npmjs.com/package/registry.npmjs.org leads to
You will note the command I used in this solution on the right side of that last screenshot.
Finally:
There is a typo in the error output: error refers to "registry.nPJMs.org", whereas the address has to be "registry.nPMJs.org".
I don't know if this should be brought to the attention of NodeJS devs, but there you go.
Add the following to node\node_modules\npm\.npmrc:
strict-ssl=false
See How to install NodeJS LTS on Windows as a local user (without admin rights) for details.
In my case, it was a weird internet connection problem. I tried to use a 4G sharing with my phone and tried to run npm install again, it worked. This way I was sure the problem was related to my connection set up and not node installation.
I unplugged my ethernet cable for 20s, plugged it in again and it worked, surprisingly.
On Ubuntu 22.10, disabling IPv6 fixed this for me.
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
To do this permanently, edit /etc/default/grub: change
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ipv6.disable=1"
and then run
sudo update-grub
One more thing that might cause this is if you have incorrectly formatted certificates added to your npm config.
To check if this is a problem you can run
npm config get cert
npm config get key
To check if there is a value there, and if they look right.
If you're not sure, make a note of the values so you can restore if necessary and then remove them from the config
npm config delete cert
npm config delete key
Then try npm install again
To add the config back use
npm config set cert "<cert>"
npm config set key "<key>"
substituting you actual cert and key, (not the file, but the cert and key text)
more info on npm config here https://docs.npmjs.com/cli/v8/using-npm/config#cert

Installing Angular CLI with npm install fails

I am new to AngularJS, just started an online course.
I am trying to install angular CLI on my computer at work running Windows 7.
I opened command line as administrator and running npm install -g #angular/cli. Installation starts and after a few minutes I get an error:
I see the notification "operation not permitted", but I am the administrator of the computer and the command line I run as administrator.
What am I doing wrong?
The same installation I did on my laptop at home and it was successful.
I am checking with our IT support about other possible causes and will appreciate any help.
This is not a duplicate of Fail to install npm package “npm ERR! errno -4048” or npm install -g angular-cli fails.
Ignoring the error and running gn -v I get the following:
Is this correct? Was Angular CLI installed?
These issues are because of the company proxy settings.
Check with your admin to get the proxy for http or https.
It will be something like this:
http_proxy = http://http.myproxy.com:8000
https_proxy = http://http.myproxy.com:8000
Replace myproxy with the name of company proxy.
Then go to the command prompt and run the following command to set the proxy. Later you can run any command like npm install -g #angular/cli to run. It will work
npm config set proxy http://http.myproxy.com:8000
npm config set https-proxy http://http.myproxy.com:8000
That fsevents library has peculiarities on Windows. So I suggest you ignore the error message and run ng -v from the command prompt to confirm you got the Angular CLI libraries installed.
You need to run the npm commands on node.js command prompt but not on windows command line.
Workaround: install git bash on windows.
As the error message suggest, you don't have some permissions to execute your command.
Depending on your system, you should run the command as an administrator.
Also, don't mix AngularJS (the first Angular framework) and Angular (also known as Angular 2, 4 and 5 now) . They are radically different in their syntax and uses.
Run below command and try installing angular cli again.
npm cache clean -f
This worked for me manytimes.

npm install command never ending on Angular 2 project

I work on an Angular 2 project and sometimes when I execute the npm install command, it's never ending. I can see a progress bar, once the bar is full a new npm install command is displayed on the command console, a new progress bar and so on.
For the moment I remove all the module under node_modules and restart the npm install from scratch but it is not acceptable.
Is this problem wellknown? Is there a solution?
Had that issue because of my connection before. Might be the same for you. Try disabling firewall. Or even try using some other internet connection outside a corporate or protected one.

Error while installing node inspector on window 7 machine

I ran following command to install node inspector.
npm install -g node-inspector
But npm gave some error. Please see below image for more information. After this I ran node-inspector command which is not recognized by the system.
This looks like npm cannot download tarballs from the public registry.
The error message ENOTFOUND means the npm was not able to resolve the IP address of registry.npmjs.org. Check your network connection and DNS configuration and make sure you can access registry.npmjs.org (e.g. run ping registry.npmjs.org).

npm install hangs

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
Very outdated npm version.
Some problem with your internet connection.
Permissions are not sufficient for npm to modify files.
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.
You can try deleting package-lock.json and running npm install afterwards.
This worked for me.
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/
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
Updating npm helped me on Mac OS. Use the command:
sudo npm install -g npm#latest
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.
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.
While your mileage may vary, running npm cache verify fixed the issue for me.
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
When your ssh key is password protected run ssh-add. npm probably hangs somewhere asking for your password.
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
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.
Surprisingly just restarting my computer and running npm install again worked for me
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.
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! 👍
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've hit this problem a couple times.
When I was on VPN, I pressed Ctrl-C and disconnected from the VPN. Then npm install worked.
When I wasn't on VPN, I pressed Ctrl-C and connected to the VPN. Then, again, npm install worked.
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 ;)
install nvm (Node Version Manager) and downgrade node version from 14 to 12 solved the issue in my case
Uninstalling and installing node and npm worked for me. I'm using Ubuntu 20.04.1 LTS
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.
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 was having this error because I was running npm in a (docker) container in WSL2, and docker in WSL2 was configuring the wrong nameservers in the containers, making the container unable to resolve hosts.
To see if your container (or even your host) can resolve hosts, you can try running: curl https://github.com. In my case I received curl: (6) Could not resolve host: github.com.
The error in the docker container doesn't happen if I don't use the default bridge, instead I used a custom bridge and defined the container with it, in which case the resolv.conf file ends up with the correct nameserver:
$ cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0
The ip 127.0.0.11 corresponds to the docker DNS server, solving the problem in my case.
If you aren't running npm in a container, your issue may still be related to some misconfigured resolv.conf file (if you are in a Linux machine, or in Windows with WSL/WSL2).
In case anyone else encounters this, I left the npm install to run for long enough, and then the Jest extension crashed (v4.2.1), at which point the npm install completed successfully.
The Jest configuration seems to show that a test auto-watch feature was enabled. I haven't changed any Jest settings as far as I'm aware, so this must be out-of-the-box functionality.

Resources