NPM doesn't install any modules: network socket hangs up - node.js

Salam (means Hello) :)
I have the latest version of node.js installed on ubuntu 12.04, I'm not behind any proxies, and my network settings are correctly configured, and were intact since last time when NPM worked fine. But now NPM hangs up installation of any modules with following error:
nasser#nasser-desktop:~/projects/server v3$ npm install simple-proxy
npm WARN package.json docco#0.6.2 No repository field.
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm http GET https://registry.npmjs.org/simple-proxy
npm ERR! network socket hang up
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.5.0-17-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "simple-proxy"
npm ERR! cwd /home/nasser/projects/serverV3
npm ERR! node -v v0.10.18
npm ERR! npm -v 1.3.8
npm ERR! code ECONNRESET
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/nasser/projects/serverV3/npm-debug.log
npm ERR! not ok code 0

i had same problem.
it seems that there is some problem with ISP's https handling. doing:
npm config set registry http://registry.npmjs.org/
worked for me

I was having the same problem. Found a solution in this thread.
You can see the effective proxy that npm is using by doing:
npm config get proxy
npm config get https-proxy
If you're behinid a proxy, try this:
mv ~/.npmrc ~/.npmrc.bak

I was having a similar issue with my windows machine and i fixed it by first checking whether my proxy got some value by executing the below command.
npm config get proxy
in return i got the below:
http://usr:pwd#host/:port
So if anyone who is not under a proxy layer first set the proxy as null by executing the below command.
npm config set proxy null
now if you excecute your npm i it should not throw any network error.

I tried multiple solution but most of cases happened with me is network/ssl and proxy issue.Network/ssl cases are very common and there are bunch of solution but with proxy thing I shared my fixes with you.
Bash Commands:
npm config set proxy null
npm config set https-proxy null
npm config set http-proxy null
in my case I'm using https://registry.npmjs.org/ url.
After NULL proxy its start working.
npm set default proxy as http://my-proxy.com:1080/ so either we have to change proxy url or null it.
To get your default proxy hit below command in your bash.
npm config get proxy

If you are behind a proxy that has username and password authentication, try setting the proxy as
npm config set proxy http://username:encodedpassword#proxyaddress:port
npm config set https-proxy http://username:encodedpassword#proxyaddress:port

Just follow these steps before you run: npm install -g #angular/cli
npm cache clean (You can even ignore if it throws an error)
npm config set strict-ssl false
npm config set proxy http://myusername:mypassword#proxyaddress:port
npm config set https-proxy http://myusername:mypassword#proxyaddress:port

Add the proxy and http_proxy field with your credentials (encoded if it contains any special characters) to your .npmrc file and run npm install again. It should work.
for example:
proxy=http://username:passcode#proxyURL:80/
https_proxy=http://username:passcode#proxyURL:80

Find .npmrc file, open with note pad. then delete the proxy setting there

Related

NPM behind a proxy : can't download any packages

I am working on a server that has access to the Internet through a proxy. I can't neither access proxy configuration nor change it.
These are the options of .npmrc :
https-proxy = "https://10.1.0.254:8080/"
proxy = "http://10.1.0.254:8080/"
strict-ssl = false
When I try to download a package I get this error prompt :
npm ERR! code EPROTO
npm ERR! syscall write
npm ERR! errno EPROTO
npm ERR! request to https://registry.npmjs.org/bower failed, reason: write EPROTO 139954307135424:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
npm ERR!
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-02-15T15_26_16_616Z-debug-0.log
I have access to https://registry.npmjs.org/ with a web browser through this proxy and the server can resolve the name. I mention that APT works perfectly.
I'm running out of ideas on how to get this working. Any ideas ?
I tried to remove .npmrc configuration and to rely only on system proxy definition. I tried to update npm and also to find other occurence of this problem here.
Don't remove the .npmrc, try to add this:
ssl-protocol=TLSv1.2
Or Alternatively try using a different registry by adding the following line to your .npmrc file::
registry=http://registry.npmjs.org/

NPM, downloads dependencies from wrong URL address

After working with some project, my npm started to download dependencies from wrong address globally:
npm install -g bower
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://172.168.1.1/bower failed, reason:
connect ETIMEDOUT 172.168.1.1
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
Is there some method to reset download address to default one?
I'm using Windows version of NodeJS
Looks like your registry npm config option points to the wrong location. It must be https://registry.npmjs.org, check it with the following command:
npm config get registry
If your registry is different, use this command to set it correctly:
npm config set registry https://registry.npmjs.org/

npm ERR! Error: connect ECONNREFUSED when trying to update the npm

I'm trying to update the npm (node package manager) using the command:
npm install npm#latest -g
but I'm getting the following error in the command prompt:
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "npm#latest" "-g"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect
npm ERR! Error: connect ECONNREFUSED xxx.xxx.xx.xxx:xxx
npm ERR! at Object.exports._errnoException (util.js:1022:11)
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
does someone know what this really means?
any help would be appreciated.
Try:
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
The first two lines will remove proxy's if there any.
Third line will make npm download from the official package registry.
If you are behind a proxy, please make sure that the npm ERR! 'proxy' config is set properly. See: 'npm help config'
See:
https://docs.npmjs.com/cli/config
More info:
How to setup Node.js and Npm behind a corporate web proxy
I have been trying to fix this issue by
npm config set registry http://registry.npmjs.org/
npm config set proxy http://myproxyblabla:myport
npm config set https-proxy http://myproxyblabla:myport
But it didn't help. The only one solution which worked for me is adding additional fields to host file (C:\Windows\System32\drivers\etc\hosts)
151.101.36.162 registry.npmjs.com
151.101.36.162 registry.npmjs.org
This allowes npm to resolve address to server from which it will download needed files.
You can get familiar with closed issue on npm repository where this solution is approved by npm contributors.
I got a similar error when I was using Node JS behind a proxy server. Here's what I had to do to fix it:
npm config set proxy http://jdoe:password123#proxy.company.com:8080
npm config set https-proxy http://jdoe:password123#proxy.company.com:8080
Just replace "jdoe" and "password123" with your own credentials to access the proxy server. Everything after the # is the server domain name, or you can enter the exact IP address too. In my case, both addresses were HTTP (not HTTPS).
To confirm the changes, you can type:
npm config list
and your settings should be listed.
You can get the proxy settings (address) from your browser too.
May be this will help someone in need. I turned to this solution after wasting good 2 hours as my corporate proxy server on work laptop was not getting resolved..!
I removed both proxy and https-proxy from .npmrc file and set only
npm config set registry http://registry.npmjs.org/
Then, I am able to successfully run npm install -g create-react-app
.npmrc file can be found here at C:\Users\<userName>\.npmrc
Cheers! Happy Quarantine Development :p
The problem here is because of proxy. So you need to run the below-mentioned command to remove the proxy and then set the registry from http://registry.npmjs.org/.
npm config set proxy null
npm config set https-proxy null
npm config set registry http://registry.npmjs.org/
And then you can create your first react app by using:
npx create-react-app your-app-name
I had the same problem with my cra and all I had to do was comment out my .npmrc, clean the cache, and run the command npx create-react-app
We faced similar issue recently and our requirement was to use public npm registry for one feature and private registry for another feature. So for private registry npm needs to go via proxy but for public registry we don't need proxy so we created .npmrc file inside our project and added two config variables:
registry and noproxy where noproxy points to the public domain of the registry. This will make sure to skip the proxy config from your global npmrc file.
I had the same error, using Mullvad VPN. It was fixed by enabling IPv6 in Mullvad settings.
We happened to run into this error message because in our setup, the Maven Nexus NPM Repository ran on the same machine and we therefore first used http://localhost/xyz/ as the NPM repository URL.
For whatever reason, localhost was treated as a system-type NPM registry, causing errors.
Changing the NPM repository URL configuration to the computer's hostname, e.g. http://mycomputer.company.intra/xyz/ fixed the issue.
What fixed it for me, was to enable SMB 1.0 in Window's Control Panel on my development PC as follows:
Control Panel > Programs and Features > Turn Windows features on or off > SMB 1.0

Resolving network tunneling socket could not be established error

While trying to install node-inspector, I am getting the error:
npm ERR! Linux 4.4.0-21-generic
npm ERR! argv "/home/hira/.nvm/versions/node/v4.4.7/bin/node" "/home/hira/.nvm/versions/node/v4.4.7/bin/npm" "install" "-g" "node-inspector"
npm ERR! node v4.4.7
npm ERR! npm v2.15.8
npm ERR! code ECONNRESET
npm ERR! network tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:5002
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request:
I basically had a project based on node's thin module, that ran an http/https mitm proxy on 127.0.0.1:5002
Reading some answers on this issue, I have tried to remove the proxy settings by using:
npm config rm proxy
npm config rm https-proxy
as well as
npm config set proxy = null
so when I do npm config ls -l it shows both settings as null. However, still it refuses to install. I have even tried to remove my systems Network Proxy settings.
Could anyone help with this issue? I am running node v4.4.7 and npm version 2.15.8 on Ubuntu 16.04 on Virtualbox. Thanks.
As indicated by robertklep and QPTR in comments, removing the environment variables solved it for me
http_proxy
https_proxy
HTTPS_PROXY
HTTP_PROXY
Below things worked for me, make sure environment variable HTTP_PROXY is unset before removing config entries. First line is very important.
set HTTP_PROXY=
npm config rm proxy
npm config rm https-proxy
npm config rm http-proxy

npm install not working

I just started learning node.js and i have installed node.js along with npm module manager.
I have created a package.json file and from the root directory iam trying to execute npm install command, instead of creating npm_modules folder it throws error like this:
C:\Users\username\Desktop\nodetest>npm install
npm WARN package.json backbone-library#0.0.1 No README.md file found!
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/path
npm http GET https://registry.npmjs.org/mongoose
npm ERR! Error: connect ETIMEDOUT
npm ERR! at errnoException (net.js:863:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:854:19)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Windows_NT 6.1.7600
npm ERR! command "D:\\Program Files\\nodejs\\\\node.exe" "D:\\Program Files\\no
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\username\Desktop\nodetest
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! syscall connect
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Users\username\Desktop\nodetest\npm-debug.log
npm ERR! not ok code 0
Iam using Windows 7 OS.
Any ideas ?
Thanks,
Srinivas
This will probably solve your problem:
npm config set proxy proxy-url:port (http:\\proxy-name:port)
npm config set https-proxy proxy-url:port
It was a stuck step on my side,
the following syntax worked for me:
npm config set proxy http:/myproxyserver:port
best regards :)
You may need to use the windows "run as" command (which is equivalent to the *nix "sudo" command) in order to have the correct privileges on your machine.
This link should be helpful: https://superuser.com/questions/42537/is-there-any-sudo-command-for-windows
finally i came to know that my company laptop has proxy restrictions.Once i got the approval for proxy removal it worked.
But still ppl, who ever facing proxy issue in npm install,can try the following method.
Go to C:\Users\YourUserName
Create a file named .npmrc (no need of any prefixname just .npmrc)
Inside that file type the following
proxy = username:password#ip:port (add http:// before username)
That's all.It is perfectly working for me....
The traceroute command will usually tell you where a connection fails and would have lead you straight to the corporate proxy in this case.
Adding to the selected answer
a) "npm config set proxy proxy-url:port (http:\proxy-name:port)
b) npm config set https-proxy proxy-url:port"
make sure you add "http:\\" to your proxy name, and packages downloaded from npm use ssl so try the second option for sure.
If you are working behind a proxy, configure it:
npm config set proxy http://login:pass#host:port
Check the value of your proxy configuration:
npm config get http-proxy
Try again to get your package...

Resources