ETIMEDOUT Error while installing Node packages on Windows - windows

I am trying to install node packages on my windows machine using npm from a fresh install of node.
however, I am getting ETIMEDOUT errors. I checked few other stackoverflow questions with similar problem and almost all of them are related to problems when behind a proxy. Same is not the case with me. My system is not behind any proxy server. Can someone help me with resolving it.
PS C:\windows\system32> npm -v
2.5.1
PS C:\windows\system32> npm install bower -g
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i
nstall" "bower" "-g"
npm ERR! node v0.12.0
npm ERR! npm v2.5.1
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect
npm ERR! network connect ETIMEDOUT
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:
npm ERR! C:\windows\system32\npm-debug.log

I am posting this answer in case some one faces the same issue.
I was able to solve this by running following command:
npm config delete proxy

First, run
npm config list
and check whether you are behind a proxy. If so, try running
npm config delete proxy
npm config delete http-proxy
npm config delete https-proxy
as required
**If this method did not work, reinstall nodejs.

I tried all the suggested solutions I could find on GitHub forums and StackOverflow topics. Finally disabling my router's firewall solved the issue immediately.
I am using Windows 10, node 4.0.0 and npm 2.13.4.

First see the npm config list:
npm config list
If you don't find http-proxy, https-proxy and proxy correctly set, then
You need to configure npm to work with your web proxy. For example:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
npm config set http-proxy http://proxy.company.com:8080

Not on Windows but it can help there as well.
Node 16 worked, Node 18 did not. Turns out it was related to IPv6. As soon as I disabled IPv6 the connection did not timeout any more. The target registry was a Nexus server.

You can try to throttle the number of simultaneous connections with the following command (for example 3 maximum simultaneous connections):
npm set maxsockets 3
The CLI has been allowing this option since npm#3.8.0. The default is 50 simultaneous connections max. See this link for further reference.

If removing the npm proxy config settings (or correctly setting them, if that is necessary for you) did not fix it, then This github issue discusses what might be happening. My summary is that for some reason the ipv6 dns resolution to the registry is not resolving correctly and seems to be randomly failing for people.
My command was fetching from registry.npmjs.org using npm 9.1.2 and node 18.12.1 - I was running this from a windows terminal via vscode.
I ended up disabling ipv6 via the network properties of my adapter see here
Again, changing the npm config proxy settings did not resolve anything for me. I re-enabled ipv6 after my command finished.

For people working in corporates (where you cannot delete or edit the proxy configuration of the organization):
There must be an .npmrc file in your users folder. If not, you can create one. This file can be edited to register the proxy settings of your organization. Contact your organization's IT team to get the relevant proxy details.
Example of the .npmrcfile contents for my organization:
strict-ssl=false
registry=https://nexus.com/nexus/content/groups/npm-read/
proxy=http://primary-proxy.gslb.intranet.com:8080/
https-proxy=http://primary-proxy.gslb.intranet.com:8080
This file can be found in your users folder:

I was not able to install any packages before because of this error then after 1 hour, I finally resolved it because I was not behind a proxy but the proxy parameters got set in the npm config thats why that error was showing.
I'am posting it because if anyone is facing the same issue and if they are not behind any proxy then they can use the following commands:-
npm config rm proxy
npm config rm https-proxy
npm config delete http-proxy
npm config delete https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null

One way to resolve this is to set Fiddler as your proxy server. This probably only works for windows.
Running Fiddler, type these commands:
npm config set proxy http://localhost:8888
npm config set https-proxy http://localhost:8888
Before you do this, Rules -> Automatically Authenticate

I solved with:
npm config set proxy null

I solved it with the following:
npm config rm proxy
npm config rm https-proxy
npm config delete http-proxy
npm config delete https-proxy
set HTTP_PROXY=null
set HTTPS_PROXY=null

I was going through the same error. the root cause was the proxy settings : there are several answers provided in here to reset the proxy but none of them worked for me.
Below commands solved my problem, give them a try.
npm config rm proxy
npm config rm https-proxy

If none of the mention solutions works for you then, try switching your node version.

I tried to implement all solutions and suggested commands for npm and yarn but it's not resolved.
When I disable my VPN and try to "yarn install, " it will work fine.

After all the effort with no result, I reboot my router and it works!

On windows 10, adding Node.js to the firewall authorized applications AND restarting the laptop solved the problem.

I also face this issue
Solution
Just uninstall Node.js .
uninstall its package also which you downloaded from website.
Download Node.js from website.
Reinstall Node.js .
It will Work.

Related

Unable to install npm package due to encoded url

So I recently got a Windows laptop at work, trying to set up my dev environment and I am getting a strange issue when trying to install our private gitlab npm packages.
I try npm install and it says it cannot find the package even though it has been published to our private registry. This seems to only be happening on my windows machine. The package can be found no problem on my macbook.
npm i
npm ERR! code E404
npm ERR! 404 Not Found - GET https://gitlab.orgname.com/api/v4/projects/118/packages/npm/#integrations%2fcommon-ui
npm ERR! 404
npm ERR! 404 '#integrations/common-ui#^1.0.4' is not in this registry.
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jack.lovett\AppData\Local\npm-cache\_logs\2022-12-13T10_08_06_142Z-debug-0.log
It seems that / in the path is being encoded to %2f so then it can't find the package anymore.
I can't find any help online for this issue so any ideas would be greatly appreciated.
The %2f part in the url seemed to not be relevant and just caused me to go down a rabbit hole of unrelated issues.
What seemed to be the problem was that i did not have NVM correctly set to my PATH in my environment variables.
When adding to path I added the location of my /node.js directory in /"Program Files"/node.js. This then added to my path the correct node version used by nvm.
I then attempted to authenticate with our private package registry again and it all worked as expected.

Getting ETimedOut error when trying to install packages using npm in windows

I'm facing this "ETimedOut" error when trying to use this command "npm install -g yo" .Actually I'm using a network proxy to access internet.
I got a warning message that "If u are behind a proxy,please make sure that 'proxy' config is set properly ".
Can anyone please help me out regarding this issue.
You can set the npm proxy config parameter using these commands:
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
Source

npm install does nothing - how make it work?

I have a trouble with npm and I haven't found solution in web.
Today I wanted to start my adventure with nodejs, npm, bower etc.
I use Windows 8.1.
I installed the newest nodejs (v0.12.0). I tried these steps with both x64 and x86 builds.
I opened nodejs command line with administrative privileges.
I updated npm to 2.5.0 version.
When I run npm install bower -g I see a char that seems to show progress (it'is rolling) but nothing happens. Even if I leave it "working" for a 30 minutes, nothing happens. It never ends.
When I type np ls -g it shows only npm#2.5.0 and it's dependencies.
I don't know what other info I could provide. There are no errors nor logs.
Please, help.
Updated
Logs:
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli 'C:\\Users\\Lucek\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli '--verbose',
npm verb cli 'install',
npm verb cli 'bower',
npm verb cli '-g' ]
npm info using npm#2.5.0
npm info using node#v0.12.0
npm verb cache add spec bower
npm verb addNamed bower#*
npm verb addNameRange registry:https://registry.npmjs.org/bower not in flight; fetching
npm verb request uri https://registry.npmjs.org/bower
npm verb request no auth needed
npm info attempt registry request try #1 at 08:43:01
npm verb request id 8d309c5e387572c0
npm verb etag "CQDT3LW680UJR78VNWVFLN8Q7"
npm http request GET https://registry.npmjs.org/bower
npm http 200 https://registry.npmjs.org/bower
npm verb get saving bower to C:\Users\Lucek\AppData\Roaming\npm-cache\registry.npmjs.org\bower\.cache.json
npm verb addNamed bower#1.3.12
npm verb addRemoteTarball https://registry.npmjs.org/bower/-/bower-1.3.12.tgz not in flight; adding
npm verb addRemoteTarball [ 'https://registry.npmjs.org/bower/-/bower-1.3.12.tgz',
npm verb addRemoteTarball '37de0edb3904baf90aee13384a1a379a05ee214c' ]
Thetoast found solution that worked for me.
If you have the same problem check the value of your TEMP environment variable. To do so run nodejs' command window and type
echo %TEMP%
You should receive path to a single directory. If you receive multiple directory (as I did - I received C:\Users\<user>\AppData\Local\Temp;c:\Users\<user>\AppData\Local\Atlassian\SourceTree\git_local\bin\) it means that this might by the cause of the problem. You can fix it by typing
SET TEMP=<correct path to temporary directory>
where <correct path to temporary directory> might by the first path (before semicolon, that means C:\Users\<user>\AppData\Local\Temp in my case).
I had some issues with the npm install bower -g aswell but try this command:
npm install bower --global
this one worked for me
I know this is an old question but i am adding this answer just for the record.
I was facing a similar issue i.e. rotating character with no progress in actual installation after trying to install using the following command on linux Mint 17(from http://bower.io/#install-bower):
npm install -g bower
The command which actually worked for me is:
npm install --global bower
Note: You will need root/administrative privelage to run this command. So you might wanna use sudo.
I was getting the same error.
But I found that this was Windows Firewall problem.
Make sure your firewall is not preventing any Incoming connections or there is no limit on TCP connections.
Just adding another solution if it helps someone - I had this issue after cloning a repo and found blowing away node_modules worked for me.
rm -rf node_modules
For me, this problem was caused by Controlled Folder Access in Windows Virus and Thread Protection > Ransomware Protection > Controlled Folder Access.
Turning this off fixed the problem.

What permissions do I need to install Bower on Vagrant on Windows?

I kept running into this error when installing Bower through NPM on a Windows 7 machine running a precise32 Ubuntu Box on Vagrant. I tried every combination of commands and always got the same or very similar errors
Installing locally, globally, with sudo, without sudo, etc.
...
npm ERR! Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js'
npm ERR! { [Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-23-generic-pae
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "bower" "--no-bin-links"
npm ERR! cwd /home/vagrant
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.24
npm ERR! path /home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, open '/home/vagrant/tmp/npm-1214-AHbOCwuM/1391873680685-0.36021817452274263/package/build/node_modules/cheerio/node_modules/htmlparser2/node_modules/readable-stream/test/simple/test-stream2-readable-empty-buffer-no-eof.js'
...
EDIT: As well as my answer below please note the file directory + file size limitation when using Windows (260 characters I believe)
I have had to install vagrant in a folder directly on my c:/ drive to get over this limitation as some packages end up having nested dependencies causing this limit to be exceeded. My problem was with grunt-contrib-less
Self answering as I couldn't find a solution anywhere else on StackOverflow
I eventually got it to work via changing to the root user via su root and trying to install globally again. Apparently just using sudo wasn't enough.
So it became
root#precise32: npm install -g bower --no-bin-links
EDIT: As well as this solution please note the file directory + file size limitation when using Windows (260 characters I believe)
I have had to init a vagrant instance in a folder directly on my c:/ drive to get over this limitation as some packages end up having nested dependencies causing this limit to be exceeded. My problem was with grunt-contrib-less
EDIT 2: After coming across this problem again and again I'll add a bit more information for people here regarding node modules and vagrant under Windows.
I now overcome the file path limitation via putting any long dependency chains that fail due to path length (usually EPERM) I add one of the packages in the chain to my own package.json. This means the long requirement chain is split as npm does not re-install the package deeper in the tree if it's already installed.
Just make sure you require a version which is valid for the version string for the module.
The order of the dependencies in package.json does not matter, dependencies are resolved before anything is installed
One of ops guys (vagrant and node.js quick tip) found a solution for that problem. Basically you need to have the following code in your Vagrant file:
config.vm.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
That will allow npm to create symlinks for the modules that require it.
Than install packages without forcing the symlinks. So, when running npm install on a virtual machine created through vagrant, run it as:
sudo npm install --no-bin-link
It was usefull for me when I installed the express
module.
With Vagrant 1.5 on Windows, you can now use rsync or smb folder shares which won't have this problem.
To get around the 260 character file length limit in windows, which npm seems to surpass quite easily, you can use the npm link command.
This will allow you to use node_modules local to your project. If you run it on your guest machine it will install them globally on your guest machine and then create a symlink in your projects node_modules folder. That way only the symlink is shared to the windows host machine and the 260 file length limit is not exceeded.
I go over this in more detail in this blog post here.

nodejs npm global config missing on windows

I can't find at all where npm has its global settings stored.
npm config get userconfig
C:\Users\Jack\.npmrc
npm config get globalconfig
C:\Users\Jack\AppData\Roaming\npm\etc\npmrc
There's no files at either of these paths and yet
npm config get proxy
-> returns my proxy url for work. which I want to delete.
npm config -g delete proxy
npm ERR! Error: ENOENT, unlink 'C:\Users\Jack\AppData\Roaming\npm\etc\npmrc'
npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "config" "-g" "delete" "proxy"
npm ERR! cwd C:\f\Dropbox\apps
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! path C:\Users\Jack\AppData\Roaming\npm\etc\npmrc
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\f\Dropbox\apps\npm-debug.log
npm ERR! not ok code 0
There is a problem with upgrading npm under Windows. The inital install done as part of the nodejs install using an msi package will create an npmrc file:
C:\Program Files\nodejs\node_modules\npm\npmrc
when you update npm using:
npm install -g npm#latest
it will install the new version in:
C:\Users\Jack\AppData\Roaming\npm
assuming that your name is Jack, which is %APPDATA%\npm.
The new install does not include an npmrc file and without it the global root directory will be based on where node was run from, hence it is C:\Program Files\nodejs\node_modules
You can check this by running:
npm root -g
This will not work as npm does not have permission to write into the "Program Files" directory. You need to copy the npmrc file from the original install into the new install. By default the file only has the line below:
prefix=${APPDATA}\npm
For me (being on Windows 10) the npmrc file was located in:
%USERPROFILE%\.npmrc
Tested with:
npm v4.2.0
Node.js v7.8.0
It looks like the files npm uses to edit its config files are not created on a clean install, as npm has a default option for each one. This is why you can still get options with npm config get <option>: having those files only overrides the defaults, it doesn't create the options from scratch.
I had never touched my npm config stuff before today, even though I had had it for months now. None of the files were there yet, such as ~/.npmrc (on a Windows 8.1 machine with Git Bash), yet I could run npm config get <something> and, if it was a correct npm option, it returned a value. When I ran npm config set <option> <value>, the file ~/.npmrc seemed to be created automatically, with the option & its value as the only non-commented-out line.
As for deleting options, it looks like this just sets the value back to the default value, or does nothing if that option was never set or was unset & never reset. Additionally, if that option is the only explicitly set option, it looks like ~/.npmrc is deleted, too, and recreated if you set anything else later.
In your case (assuming it is still the same over a year later), it looks like you never set the proxy option in npm. Therefore, as npm's config help page says, it is set to whatever your http_proxy (case-insensitive) environment variable is. This means there is nothing to delete, unless you want to "delete" your HTTP proxy, although you could set the option or environment variable to something else and hope neither breaks your set-up somehow.
How to figure it out
Start with npm root -- it will show you the root folder for NPM packages for the current user.
Add -g and you get a global folder. Don't forget to substract node_modules.
Use npm config / npm config -g and check that it'd create you a new .npmrc / npmrc file for you.
Tested on Windows 10 Pro, NPM v.6.4.1:
Global NPM config
C:\Users\%username%\AppData\Roaming\npm\etc\npmrc
Per-user NPM config
C:\Users\%username%\.npmrc
Built-in NPM config
C:\Program Files\nodejs\node_modules\npm\npmrc
References:
https://docs.npmjs.com/files/npmrc
https://docs.npmjs.com/misc/config
https://docs.npmjs.com/cli/root.html
Have you tried running npm config list? And, if you want to see the defaults, run npm config ls -l.
Even though we have the .NPMRC can be in 3 locations,
Please NOTE THAT - the file under the Per-User NPM config location take precedence over the Global & Built-in configurations.
Global NPM config => C:\Users\%username%\AppData\Roaming\npm\etc\npmrc
Per-user NPM config => C:\Users\%username%.npmrc
Built-in NPM config => C:\Program Files\nodejs\node_modules\npm\npmrc
To find out which file is getting updated, try setting the proxy using the following command
npm config set https-proxy https://username:password#proxy.company.com:6050
After that open the .npmrc files to see which file get updated.
Isn't this the path you are looking for?
C:\Program Files\nodejs\node_modules\npm\npmrc
I know that npm outputs that , but the global folder is the folder where node.js is installed and all the modules are.
On windows, used the below command that listed down all the default values for npm including the location of config file with variable name userconfig
npm config ls -l

Resources