How to install node packages in ubuntu server with IPv6 only - node.js

I'm trying to install typescript on an Ubuntu server where only IPv6 address space is available.
I'm getting error as follows. Any help?
:/home/dev/.nvm# npm install --global typescript
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/typescript failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
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:
npm ERR! /root/.npm/_logs/2017-11-01T19_15_39_294Z-debug.log
The error of this network connectivity happens with many packages and even github. I installed nvm in a slightly different way by setting the codebase in bitbucket.
I tried to install npm and n to setup typescript using n. That failed and I started using nvm as alternative. PFB the logs when trying to install n.
:~# sudo npm install -g n
npm ERR! Linux 4.4.0-98-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "n"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ENETUNREACH
npm ERR! errno ENETUNREACH
npm ERR! syscall connect
npm ERR! connect ENETUNREACH ::ffff:151.101.208.162:80 - Local (:::0)
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /root/npm-debug.log
I just need some way to get it installed but no luck! I strongly believe it is IPv6 issue and looking for work around.
Btw, my ubuuntu server is 16.04.3 LTS. I have installed it successfully on IPv4 servers running on Ubuntu 16.10 and 17.04 version and here in Production, I'm locked!

I got that working after a change in registry. Could be a network problem that I faced on server OR the IPv6 only issue. Anyway the change in registry worked perfect.
sudo npm --registry http://registry.node-modules.io/ install n -g
After all the link below guided me to the answer.
Node-modules.io
Hope this will help somebody for the future reference!
Thanks for #Kalana Demel for the help to reach me to the answer.

Another workaround which will also work for yarn, is to add the resolved ip6s to /etc/hosts :
2606:4700::6810:1723 registry.yarnpkg.com
2606:4700::6810:1723 registry.npmjs.org
2606:4700::6810:ab63 yarnpkg.com
You can get the ip6s with nslookup registry.yarnpkg.com, nslookup ….

It seems the issue might be with proxy setting try using http instead of https, ipv6 issues seems to be resolved in the newer versions of npm as well.
npm config set registry http://registry.npmjs.org/
npm cache clean
Update
It seems that the issue which was supposed to be fixed in 8.5.0 is still there, so for IPV6 only networks npm is still not working even though Node is now passing the necessary flags, so till it's fixed you will have to find a workaround.
For more info : Node, NPM

Related

Linux terminal, npm install ETIMEDOUT

I installed nodeJs and npm using nvm, that went perfectly, then I notice that a newer version of npm was available so i try
npm install -g npm#latest
But then it just stays as like that, it's like it does not start never, so I try another command and this happens
npm install -g n
Same thing, noting happens.
Trying and trying I manage to get the following error:
/home/jonathan/.nvm/versions/node/v18.12.1/bin/npx --yes --package #angular/cli ng new untitled --defaults
npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to https://registry.npmjs.org/#angular%2fcli failed, reason: connect ETIMEDOUT 2606:4700::6810:1123:443
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:
npm ERR! /home/jonathan/.npm/_logs/2022-12-28T05_07_38_682Z-debug-0.log
Done
So searching on the internet I found the url npm uses to attempt the installs the following:
registry.npmjs.org <
I tried then:
ping registry.npmjs.org
Same as above, it does nothing, it suppose to show some info every few seconds but nothing happens so y put the url in a browser and it works
{"db_name":"registry","engine":"couch_bt_engine","doc_count":3313520,"doc_del_count":332,"update_seq":31421891,"purge_seq":0,"compact_running":false,"sizes":{"active":69891815727,"external":214417993712,"file":70327402736},"disk_size":70327402736,"data_size":69891815727,"other":{"data_size":214417993712},"instance_start_time":"1672130582611333","disk_format_version":7,"committed_update_seq":31421891,"compacted_seq":31421548,"uuid":"3a4ad341a4111dd254daa731f37b37ae"}
That's what it shows.
So. I don't know what it's going on, I'm not using any proxy or firewall. Need some help here.
Update... I try using wifi not wired connection and it works, so the problem appears to be wired connection
Solution remains on network configuration, as Robert says its not related to programming so I'm marking this as answer. Thank any who try to help

Is there a way to solve ECONNRESET error when using npm? I need to restart the machine to fix it

After using the computer for a while I cant use npm install anymore. If I restart the computer then all gets back to working.
I am using macOS Mojave 10.14.3 with node v11.12.0 and npm 6.9.0.
Tried the solutions here: npm not working - "read ECONNRESET" but no success
npm i faker
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/faker failed, reason: read ECONNRESET
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:
npm ERR! /Users/flaviomelo/.npm/_logs/2019-03-28T12_25_35_242Z-debug.log
It is always possible that for a few minutes, NPM was down - so try again now just in case.
But in general, I would start by trying to find where the problem lies.
Try this:
curl https://registry.npmjs.org/faker
That should produce pages and pages of JSON. If it doesn't, then it's possible that your terminal - for whatever reason - cannot access the internet. Comments below this answer have further steps you can try in debugging this.
If it does produce lots of JSON, then there is a problem in your version of NPM / node. As these seem to be the latest, try downgrading each to see if it's a new bug.
you can try these solutions
Solution 1:
MAC + LINUX
run this command with sudo
sudo npm install -g yo
Windows
run cmd as administrator and then run this command again
Solution 2:
run this command and then try
npm config set registry http://registry.npmjs.org/

NPM issue on Mac

I had been using VS Code for my development works, when all of a sudden my npm install commands stopped working and started giving me errors like below:
⸨░░░░░░░░░░░░░░░░░░⸩ ⠧ rollbackFailedOptional: verb npm-session abcd123456789efg
npm ERR! code ECONNRESET
npm ERR! errno ECONNRESET
npm ERR! network request to https://registry.npmjs.org/passport failed, reason: read ECONNRESET
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:
npm ERR! /Users/ajaywadhwani/.npm/_logs/2019-01-27T22_33_38_087Z-debug.log
I am not behind any proxy by any chance.
Interestingly, a ping to the link https://registry.npmjs.org/passport through my browser takes me to the webpage with the content, and can ping the website through terminal.
Kindly advise and suggest.
Try updating to the latest npm with the command npm install npm#latest -g.
I would also make sure there's no proxy set up by going to System Preferences > Network > your connection (Wi-Fi, for example) > Advanced... > Proxies and looking for any checked boxes.
Please let me know if these solutions work or not.

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/

windows: npm install getting error ERR! code ECONNRESET

I try to install ionic, but when run npm install -g ionic I have error below.
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code ECONNRESET
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 settin
gs.
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'
My network don't have proxy, and when i run npm get proxy it said null
I already try to clean cache, and change registry to http://registry.npmjs.org/ and https://registry.npmjs.org/ and also I can access http://registry.npmjs.org/yo, but still have same error when installing ionic.
hope any solution for my issue.
Thank you,
There is some dependency problem.
see below link :
http://ionicframework.com/docs/concepts/development.html
Improved answer Below :
By default, brew install latest stable version of node (in this case 0.12.4). Based on the warning messages, ionic is expecting a lower version of node.
I was able to to solve this issue by installing a prior version of node (0.10.38).
$ brew remove node
$ rm ~/.node (might want to rename instead)
$ brew install homebrew/versions/node010
$ node --version
$ v0.10.38
Run npm install -g ionic worked as expected.

Resources