npm install not working - node.js

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...

Related

Inconsistent behavior while installing npm module

I am installing a npm module which use cmake-js inside it. (I mentioned cmake-js just for the information). I am behind a corporate proxy. (I have set proxy settings property). I have already set following configurations.
npm config set proxy http://xxxx:yyyy
npm config set https-proxy http://xxxx:yyyy
npm config set registry=https://registry.npmjs.org/
npm config set strict-ssl false
My npm version is 6.4.1. I can build the module without any problem when I switch to node version 8.10.0 using sudo n 8.10.0.
But when I move to node 8.0.0 version, I am getting the following error.
> cmake-js compile
info TOOL Using Unix Makefiles generator.
info TOOL Using c++11 compiler standard.
info DIST Downloading distribution files.
http DIST - https://nodejs.org/dist/v8.0.0/SHASUMS256.txt
ERR! OMG tunneling socket could not be established, cause=read ECONNRESET
ERR! OMG tunneling socket could not be established, cause=read ECONNRESET
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ur-node#1.0.0 install: `cmake-js compile`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ur-node#1.0.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/malintha/.npm/_logs/2018-09-17T14_23_42_781Z-debug.log
It seems like proxy issue, but it is working fine with node 8.10.0
What is the possible reason for this issue? Appreciate any insight to solve this issue.

npm not installing packages even after proxy is set

I am trying to set up a node js based application in one of our lab servers where connectivity to internet is achieved via a proxy. The box is running Ubuntu 13.10. I have configured the network proxy and I am able to connect to internet through Firefox. For apt-get, I have configured the proxy in /etc/apt/apt.conf. This is also working.
After installing node js, when I try to do npm install -g <package> it's giving me errors. I have configured the proxy for npm too. My .npmrc looks like this: (my proxy does not require userid/password).
registry = http://registry.npmjs.org/
proxy = http://<domain>:8080/
https-proxy = http://<domain>:8080
I have tried various options found in forums, but none seems to work for me. (Like setting strict-ssl to false, using --without-ssl --insecure option etc.)
This is the error I am getting currently:
npm http GET http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/express
npm ERR! Error: connect ECONNREFUSED
npm ERR! at errnoException (net.js:904:11)
npm ERR! at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR! { [Error: connect ECONNREFUSED]
npm ERR! code: 'ECONNREFUSED',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! syscall: 'connect' }
npm ERR!
npm ERR! If you are behind a proxy, please make sure that the
npm ERR! 'proxy' config is set properly. See: 'npm help config'
npm ERR! System Linux 3.11.0-12-generic
npm ERR! command "/home/<user>/apps/node-v0.10.26-linux-x86/bin/node" "/home/<user>/apps/node-v0.10.26-linux-x86/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/<user>
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! syscall connect
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! stack Error: connect ECONNREFUSED
npm ERR! stack at errnoException (net.js:904:11)
npm ERR! stack at Object.afterConnect [as oncomplete] (net.js:895:19)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/<user>/npm-debug.log
npm ERR! not ok code 0
Any idea, what's going wrong here? I'm stuck with this darn thing for the day ;-(
Thanks!
I haven't been able to get a resolution for this issue, but found a work around - I bundled the packages I require on my laptop and then resorted to offline installation on the lab box. Here is how to do that:
Take for example, mongodb node module. I have it installed on my laptop where I do the development. If you open the package.json file for mongodb module, the dependencies are listed with corresponding version numbers. Mine looks like this:
"dependencies": {
"bson": "0.2.5",
"kerberos": "0.0.3"
},
Update the package.json file to include "bundledDependencies". (the position shouldn't really matter, just that it should be at the same level, as a sibling of "dependencies" in the JSON tree). This is what you need to add:
"bundledDependencies": [
"bson",
"kerberos"
],
Now, while you are within your package's directory (where the package.json file is present), run the command npm pack. That will create a tgz file for you. In my case it created mongodb-1.3.23.tgz. Just copy this file to the box where you want to install it and run npm install ./mongodb-1.3.23.tgz. That should get you through. Since all dependencies are now bundled within this .tgz file, npm won't try to connect to internet for installing any of them.
However, I would still like to know what's going wrong with my internet based installation. That's still a mystery!

npm install throwing errors Error: Invalid protocol

Hi I am new to Node JS and i am trying to follow the sample in the book and when trying to do npm install i get the following error:
Any help will be highly appreciated
C:\Developer\NODE_JS>npm install
npm WARN package.json chatrooms#0.0.1 No repository field.
npm WARN package.json chatrooms#0.0.1 No README data
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/mime
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/mime
npm http GET http://registry.npmjs.org/socket.io
npm http GET http://registry.npmjs.org/mime
npm ERR! Error: Invalid protocol
npm ERR! at Request.init (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:335:51)
npm ERR! at new Request (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:99:8)
npm ERR! at request (C:\Program Files\nodejs\node_modules\npm\node_modules\request\index.js:55:11)
npm ERR! at RegClient.makeRequest (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:211:13)
npm ERR! at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:117:17)
npm ERR! at null._onTimeout (C:\Program Files\nodejs\node_modules\npm\node_modules\retry\lib\retry_operation.js:32:10)
npm ERR! at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Developer\NODE_JS
npm ERR! node -v v0.10.24
npm ERR! npm -v 1.3.21
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! C:\Developer\NODE_JS\npm-debug.log
npm ERR! not ok code 0
My Node js config is
C:\Developer\NODE_JS>npm config list
; cli configs
registry = "http://registry.npmjs.org/"
; userconfig C:\Users\<uname>\.npmrc
https-proxy = "proxy.<comp>.com:8080"
proxy = "proxy.<comp>.com:8080"
registry = "http://registry.npmjs.org/"
; builtin config undefined
prefix = "C:\\Users\\puppalap\\AppData\\Roaming\\npm"
; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = C:\Developer\NODE_JS
; HOME = C:\Users\<uname>
; 'npm config ls -l' to show all defaults.
The issue got resolved after i set the following two properties:
npm config set proxy http://usr:pwd#host:port
npm config set https-proxy http://usr:pwd#host:port
Issue is due to windows http_proxy environment variable being set; while I don't use a proxy.
Following command in command prompt will display, if http_proxy is set;
set http
If set removed the variable with below command and problem solved.
set http_proxy=
Above command will remove the http_proxy from the current
command line. However, if you need to permanently remove it, just
remove it from System Properties>Advanced Tab>Environment Variables
dialog box.
Just want to share a method,the way i followed to get it resolved,
My error: was ERR! Error: Invalid protocol : myusername:
[username of the previous proxy]
where my .npmrc file
contains registry="http://registry.npmjs.org/"
and other variables[prefix,cwd,home]
As i am not behind the proxy, removed proxy variables
still got the same error
when looked into
request.js[/usr/lib/node_modules/npm/node_modules/request/request.js]
file it is using the old proxy values
Hence , i added the line in init() of request.js
self.proxy="http://registry.npmjs.org/" //at the start of method
then it started working!!!
PS: Once after install command,Removed this line and it continued to work.
Try this , if no other options are working
If you're on a Linux box make sure you set the following variables:
export http_proxy="http://yourCompanyProxy:portNumber"
export https_proxy="http://yourCompanyProxy:portNumber"
export HTTP_PROXY="http://yourCompanyProxy:portNumber"
export HTTPS_PROXY="http://yourCompanyProxy:portNumber"

npm install gives unauthorized name or password is incorrect error

When I try to install tap using
npm install tap
I get the following error:
npm ERR! Error: unauthorized Name or password is incorrect.: tap
Here's the entire response:
npm http GET https://registry.npmjs.org/tap
npm http 401 https://registry.npmjs.org/tap
npm ERR! Error: unauthorized Name or password is incorrect.: tap
npm ERR! at RegClient.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:253:14)
npm ERR! at Request.init.self.callback (/usr/local/lib/node_modules/npm/node_modules/request/main.js:120:22)
npm ERR! at Request.EventEmitter.emit (events.js:91:17)
npm ERR! at Request.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/request/main.js:648:16)
npm ERR! at Request.EventEmitter.emit (events.js:115:20)
npm ERR! at IncomingMessage.Request.start.self.req.self.httpModule.request.buffer (/usr/local/lib/node_modules/npm/node_modules/request/main.js:610:14)
npm ERR! at IncomingMessage.EventEmitter.emit (events.js:115:20)
npm ERR! at IncomingMessage._emitEnd (http.js:366:10)
npm ERR! at HTTPParser.parserOnMessageComplete [as onMessageComplete] (http.js:149:23)
npm ERR! at CleartextStream.socketOnData (http.js:1366:20)
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 Linux 3.2.0-31-generic-pae
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "tap"
npm ERR! cwd /home/thaddeus
npm ERR! node -v v0.8.8
npm ERR! npm -v 1.1.59
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/thaddeus/npm-debug.log
npm ERR! not ok code 0
Found the answer.
Remove .npmrc from my home directory and it works!
Thanks to mcollina https://github.com/mcollina at https://github.com/isaacs/npm/issues/2778
1.>Go to your this location
C:\Users\{your user name or ID}
2.> open .npmrc & Remove all content from .npmrc file.
3.>reopen your new command prompt
4.>again run the code , will work.
I was also having this problem. Mine has arised because I have changed my password in npmjs.org. So, try Login in npm from terminal again with your new password and then install any module. It worked for me.
You might have _auth entry configured in the .npmrc config file ($HOME/.npmrc). Just delete the entry if you are using the public registry as it's not needed. If you're using a private npm registry you should check with your admin that that's the correct auth key for you to access the registry.
I would not recommend just deleting the whole file (.npmrc) as the file might contain important configurations for your npm to work correctly. i.e.: proxy config.
Removing package-lock.json and node_modules did the trick in my case.
Also you can use
npm cache clean
i tried
npm cache clean
but it didn't work. I didn't see .npmrc in my directory. I killed my bash shell (terminal on mac) and brought up a new one and that seemed to do the trick. Not sure if it was the bash refresh or the npm cache clean or a combination of the two.
npm cache verify
is what you need
If you have changed your system LAN password, run npm login and provide your new password.
Once the login is successful, you will not get error while doing npm install.
I had a an odd issue where I got the credentials error and it was because npm login had cached bad credentials and then npm logout didn't clear the credentials (as evidenced by "npm login" always showing my default details).
NPM stores your login under the globals NPM_CONFIG_EMAIL and NPM_CONFIG__AUTH. If you do "npm config ls -la" and see email under "environment configs" you may have the same issue I had (where npm logout didn't work).
Unset the globals NPM_CONFIG__AUTH and NPM_CONFIG_EMAIL and then npm login again and it should work.
(in terminal it's just "unset NPM_CONFIG__AUTH")
For me I needed to create a account in npm site, after that sing in via terminal into npm using npm login, remove the .npmrc file from your /home folder and after that try npm install again in your project folder
In our case, our NPM repository is actually managed by our company, so our value for "registry=xxx" inside my global .npmrc file was different in our case. Verify with your company if you guys handle your NPM registries differently then using the npm site itself.

Can't install any packages in Node.js using "npm install"

I'm new to Node.js, and I'm going through a few tutorials.
For some reason, I can't install any new node modules.
I am using:
Mac OSX 10.7.4,
Node v. 0.8.6,
NPM v. 1.1.48.
I run npm install X and I always get a
npm ERR! fetch failed https://registry.npmjs.org/-/X
npm ERR! Error: 404 Not Found
When I actually go to the npmjs registry, I can see the project page, but no matter which tarball link I hit, it's always the same:
{
"error": "not_found",
"reason": "document not found"
}
For example, I tried installing fs by running npm install fs and I get:
npm http GET https://registry.npmjs.org/fs
npm http 200 https://registry.npmjs.org/fs
npm http GET https://registry.npmjs.org/-/fs-0.0.0.tgz
npm http 404 https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! fetch failed https://registry.npmjs.org/-/fs-0.0.0.tgz
npm ERR! Error: 404 Not Found
npm ERR! at null.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/fetch.js:47:16)
npm ERR! at EventEmitter.emit (events.js:115:20)
npm ERR! at WriteStream.flush (fs.js:1514:12)
npm ERR! at fs.close (/usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:92:5)
npm ERR! at Object.oncomplete (fs.js:297:15)
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 Darwin 11.4.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "fs"
npm ERR! cwd /Users/comocomo/Documents/workspace/nodeTest
npm ERR! node -v v0.8.6
npm ERR! npm -v 1.1.48
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/comocomo/Documents/workspace/nodeTest/npm-debug.log
npm ERR! not ok code 0
I tried fs, fs-extra, express, and formidable, all giving me the same 404 response.
There must be something wrong on my part, I'm pretty sure the whole registry is not broken.
Am I using an old registry? Should I change it in my config file? I honestly would rather not start installing things manually, and I'm sure it's just a small configuration issue.
Thanks!
I found the there is a certificate expired issue with:
npm set registry https://registry.npmjs.org/
So I made it http, not https :-
npm set registry http://registry.npmjs.org/
And have no problems so far.
The repository is not down, it looks like they've changed how they host files (I guess they have restored some old code):
Now you have to add the /package-name/ before the -
Eg:
http://registry.npmjs.org/-/npm-1.1.48.tgz
http://registry.npmjs.org/npm/-/npm-1.1.48.tgz
There are 3 ways to solve it:
Use a complete mirror:
Use a public proxy:
--registry http://165.225.128.50:8000
Host a local proxy:
https://github.com/hughsk/npm-quickfix
git clone https://github.com/hughsk/npm-quickfix.git
cd npm-quickfix
npm set registry http://localhost:8080/
node index.js
I'd personally go with number 3 and revert to npm set registry http://registry.npmjs.org/ as soon as this get resolved.
Stay tuned here for more info: https://github.com/isaacs/npm/issues/2694
Npm repository is currently down.
See issue #2694 on npm github
EDIT:
To use a mirror in the meanwhile:
npm set registry http://ec2-46-137-149-160.eu-west-1.compute.amazonaws.com
you can reset this later with:
npm set registry https://registry.npmjs.org/
source
This error might also occur due to proxy settings, once check that your proxy allow the access to npm commands.
It worked for me quite well.
npm set registry http://85.10.209.91/
(this proxy fetches the original data from registry.npmjs.org and manipulates the tarball urls to fix the tarball file structure issue).
The other solutions seem to have outdated versions.
If you happened to run npm install command on Windows, first make sure you open your command prompt with Administration Privileges. That's what solved the issue for me.
Check under security settings
Allow Apps Downloaded from:
App Store and other identified developers
This was one of the reasons I faced recently.

Resources