how to fix connect ENETUNREACH on npm on linux - node.js

i am not using a proxy im just a noob trying to learn how to develop with create-react-app locally on my machine(linux)
this is the output of tracepath registry.npmjs.org
1?: [LOCALHOST] 0.020ms pmtu 1500
1: 2001:4451:664:1400:caf6:c8ff:fef2:bdcb 2.906ms !N
1: 2001:4451:664:1400:caf6:c8ff:fef2:bdcb 0.995ms !N
Resume: pmtu 1500
i think this proves im not using a proxy.
but i keep getting this error
npm ERR! code ENETUNREACH
npm ERR! syscall connect
npm ERR! errno ENETUNREACH
for anything npm. i dont know what to do.
i have tried..
deleting the package.json in my home directory. deleting the
package-lock.json in my home directory. deleting the .npm directory
in my home direcory.
clearing the cache with the npm config command
setting https-proxy from the config to null setting proxy from the
config to null setting the registry to https://registry.npmjs.org
setting the registry to htpp://registry.npmjs.org uninstalled npm
and dependencies then reinstalled unintsalled npm and dependencies then installed nvm and reinstalled node through that
npm install --verbose doesnt say any error messages
please somebody help me, i try just about anything shy of reinstalling my os.

The issue is that node 18 (not happening on 16) is trying to resolve by ipv6 first.
Can override it by exporting the environment variable:
NODE_OPTIONS = "--dns-result-order=ipv4first"

Related

npm ERR! code ERR_SOCKET_TIMEOUT npm ERR! network Socket timeout

This the error:
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
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'
I have running: -npm cache clean --force
Deleted node_modules and lock-package.json and run npm install but still got me that error
Try this answer
or run npm i -g npm#8.5.1
i think it's an issue with npm version , 8.5.1 solves the problem in most cases
basically try earlier versions and i think the problem will be solved
I faced this error some days ago. I changed the timeout and it works for me. (Note: my npm version is 8.19.1)
You can try this solution with other npm versions as well.
First of all, check the current settings. For checking the current settings run npm config ls -l or grep fetch
Then, check these 4 values (fetch-retries, fetch-retry-factor, fetch-retry-maxtimeout, fetch-retry-mintimeout, fetch-timeout)
$ npm config ls -l | grep fetch
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
For changing the time out, Run these two commands-
npm config set fetch-retry-mintimeout 20000
npm config set fetch-retry-maxtimeout 120000
I faced this problem recently. I tried many solutions like npm cache verify, npm cache clean --force, npm config set fetch-retry-mintimeout, npm config set fetch-retry-maxtimeout, deleting package-lock.json, using different version of npm and/or node.
But the solution that worked for me was to switch to yarn.
I solved this by setting a timeout of 60000 for npm in the .npmrc file. To do that from your terminal, simply do the following:
$ nano .npmrc from your work directory if you want a configuration locally.
Add timeout=60000, save and you're good to go.
Originally posted here: https://github.com/facebook/create-react-app/issues/10251
You can resolve this using YARN package manager. yarn create react-app my-app
hope it help.
I am not sure if this will help anyone else, but what appears to have worked for me was dropping my company's VPN connection and reestablishing it!
In my scenario, it was the yarn.lock file availability. So the installer tried to fetch dependencies and threw an error since the response time was delayed. So deleted both yarn.lock and package.lock file and reinstalled after setting npm to npm#8.5.1
I found solution for it, which works great for me
1.npm config set registry http://registry.npmjs.org/
2.npm i or npm i --save --legacy-peer-deps
Try removing proxy settings by running the commands below:
$ npm config rm proxy
$ npm config rm https-proxy
mine worked using these steps, hope it works for you too.
npm cache clean --force
npm uninstall -g create-react-app
npm uninstall create-react-app
and then
npx create-react-app project-app
if it does not then probably your internet connection is poor or there is a proxy set up error. let me know if it does not work.

Error while trying to create react app using npm

I'm trying to creating react app using create-react-app command but I get this error message:
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/dotenv-expand: Socket timeout
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! C:\Users\IMAD\AppData\Local\npm-cache\_logs\2022-02-12T18_27_46_293Z-debug-0.log
I tried to clean cache:
npm cache clean -f
I also tried restarting the computer and reinstall nodejs and npm, but nothing was fixed.
Can anyone know what is the issue? and how can I solve it?
You should use npx command (not npm) like that as in official documentation : https://reactjs.org/docs/create-a-new-react-app.html
npx create-react-app my-app
After more than 3 days of working on this error, I found the solution and fixed the problem by install another version of Nodejs.
The current version was v16.14.0 when I got this error. And now it's v16.0.0 and everything's is work just fine.
New versions of nodejs are not stable, downgrade to 16.0.0 was the better thing i made.
I solved this using the following command.
npm uninstall -g create-react-app
then
npm install -g create-react-app

Vue CLI SOCKET_TIMEOUT error creating new project (npm error)

So basically I am trying to set up a new Vue project using vue create vue-first-app and I end up with this error below. I tried to increase the timeout using npm install -timeout=9999999 . I also tried cleaning the npm cashe with npm cache clean --force but it did not help. Does anyone know a way to solve this?
Vue CLI v4.5.9
✨ Creating project in /home/marius/vue/vue-first-app.
🗃 Initializing git repository...
⚙️ Installing CLI plugins. This might take a while...
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! request to https://registry.npm.taobao.org/mkdirp failed, reason: Socket timeout
npm ERR! A complete log of this run can be found in:
npm ERR! /home/marius/.npm/_logs/2020-12-14T09_54_21_447Z-debug.log
ERROR command failed: npm install --loglevel error --legacy-peer-deps
Try
Either:
sudo npm cache clean -f
npm update
npm update -g #vue/cli
vue create vue-first-app
OR
Point the npm registry url to http :
npm config set registry="http://registry.npmjs.org/"
And then re-run your vue cli command :
vue create vue-first-app
This may help you.
Check if you have a working internet connection (check if the firewall is not blocking the connection request)
Try to go the npm config file and change the time out from there. This issue is commonly caused when one of these two reasons occur. Path: installationDirectory\nodejs\node_modules\npm and open the .npmrc file and try changing the time out from there.
Also refer: https://docs.npmjs.com/common-errors
Had the same problem.
For me, using sudo worked.
sudo vue create vue-first-app
Good luck!
I had a similar problem, for me it worked changing the useTaobaoRegistry to false in the config .vuerc, it should be located on C:/User/your_name/
{
"packageManager": "npm",
"useTaobaoRegistry": false
}
Thanks to fangbinwei for the solution:
https://github.com/vuejs/vue-cli/issues/6003#issuecomment-716158880

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

Getting errors with npm when installing nativescript

i am trying to install nativescript, i am new to it so i'll appreciate any help..
first , i installed it correctly but after that i saw a page on nativescript site for advanced installation, so i played around with it .. now i cannot run the command tns and cannot uninstall, can`t install..
here is the errors i get:
note: I also updated my nodejs to the newest version , but couldnt update npm , when i tried to run: npm install npm -g i got errors like here:
i also tried rebooting the pc but didn`t help.
i uninstalled node, npm then installed them again .. now i get this error :
ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
ERR! network This is most likely not a problem with npm itself
ERR! network and is related to network connectivity.
ERR! network In most cases you are behind a proxy or have bad network settings.
ERR! network
ERR! network If you are behind a proxy, please make sure that the
ERR! network 'proxy' config is set properly. See: 'npm help config'
ERR! Please include the following file with any support request:
ERR! C:\Users\Home\npm-debug.log
It was a connection problem.
I remember thatI played with proxy configuration by mistake like this :
npm config set proxy http://localhost:8080/
npm config set https-proxy http://localhost:8080/
npm config set strict-ssl false
which made npm client attempts to hit localhost:8080 to pull the module rather than the correct internet endpoint.
so after couple of days of frustration i visited this link
https://docs.npmjs.com/cli/config
then run
npm config edit
which opened a file inside that file i removed those three lines i added above , then everything worked fine.

Resources