npm not installing packages even after proxy is set - node.js

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!

Related

Mongodb EHOSTUNREACH on Openshift Online 3 starter

I was working on my Openshift app today and without changing anything related to mongodb connection I started getting this message:
/opt/app-root/src/node_modules/mongodb/lib/server.js:242
process.nextTick(function() { throw err; })
^
Error: connect EHOSTUNREACH 172.30.173.215:27017
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1086:14)
npm info lifecycle bolao_2018#0.1.0~start: Failed to exec start script
npm ERR! Linux 3.10.0-693.21.1.el7.x86_64
npm ERR! argv "/opt/rh/rh-nodejs6/root/usr/bin/node" "/opt/rh/rh-nodejs6/root/usr/bin/npm" "run" "-d" "start"
npm ERR! node v6.11.3
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! bolao_2018#0.1.0 start: `node main`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bolao_2018#0.1.0 start script 'node main'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the bolao_2018 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node main
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs bolao_2018
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls bolao_2018
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /opt/app-root/src/npm-debug.log
The one thing different was that I saw that for some reason the mongodb service tried and failed a new deploy so I ran one manually.
I also noticed that the IP addressit tries to connect is mongodb's cluster IP but the Node IP of the current running pod is different.
Can someone help me figure out what triggered the connection to break?
Thanks
From within a given Project scope, requests directed toward a hostname of "mongodb" should be routed to the Kubernetes Service named "mongodb" (when available).
To debug this connectivity issue:
Try opening a live terminal within your front-end container using the OpenShift web console. The front-end container must be within the same Project scope as the database service
Type env to list environment variables available to the front-end. If this container was started after the creation of the "mongodb" service, configuration strings should be visible the environment
Run curl $MONGODB_SERVICE_HOST:$MONGODB_SERVICE_PORT from the live terminal to verify the availability of the mongodb service

Node.js ECONNREFUSED when trying to install packages

I'm working the learnyounode tutorial to learn node.js. I'm getting an error any time I try install a package.
npm ERR! Linux 4.2.0-c9
npm ERR! argv "/home/ubuntu/.nvm/versions/node/v4.1.1/bin/node" "/home/ubuntu/.nvm/versions/node/v4.1.1/bin/npm" "install" "through2-map" "--save"
npm ERR! node v4.1.1
npm ERR! npm v3.7.5
npm ERR! code ECONNREFUSED
npm ERR! errno ECONNREFUSED
npm ERR! syscall connect
npm ERR! Error: connect ECONNREFUSED 127.0.0.1:15443
npm ERR! at Object.exports._errnoException (util.js:837:11)
npm ERR! at exports._exceptionWithHostPort (util.js:860:20)
npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1060:14)
npm ERR! { [Error: connect ECONNREFUSED 127.0.0.1:15443]
npm ERR! code: 'ECONNREFUSED',
npm ERR! errno: 'ECONNREFUSED',
npm ERR! syscall: 'connect',
npm ERR! address: '127.0.0.1',
npm ERR! port: 15443 }
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! Please include the following file with any support request:
npm ERR! /home/ubuntu/workspace/npm-debug.log
I also did npm config ls to see if there was anything out of the ordinary with my configuration but really I don't know what I'm looking for. Can someone help me figure out how to fix this error so that I can install packages.
; cli configs
user-agent = "npm/3.7.5 node/v4.1.1 linux x64"
; userconfig /home/ubuntu/.config/how-to-npm/npmrc
//localhost:15443/:always-auth = false
//localhost:15443/:email = "rawledjuglal#gmail.com"
//localhost:15443/:username = "rawlejuglal"
; node bin location = /home/ubuntu/.nvm/versions/node/v4.1.1/bin/node
; cwd = /home/ubuntu/workspace
; HOME = /home/ubuntu
; "npm config ls -l" to show all defaults.
Set your NPM registry back to registry.npmjs.org:
npm set registry https://registry.npmjs.org
your npmrc file is trying to send you to a registry host on localhost:15443, delete those three lines with // from your npmrc file and try npm installing again. This should send you to the npm registry, where that package exists.
I also fetch is problem. I hope following information may help someone else like me.
For me, the reason was .npmrc where registry was set to http://localhost:15443/
.npmrc is one of sources from where npm gets its config settings. You will get more information about .npmrc file from
here
How I troubleshoot
I have used command npm config ls -l that show npm configuration list where I found that registry https://registry.npmjs.org/ is overridden.
Part of my configuration
; project config /home/sumon/projects/codecamp-node/.npmrc
registry = "http://localhost:15443/"
userconfig = "/home/sumon/.config/how-to-npm/npmrc"
; userconfig /home/sumon/.config/how-to-npm/npmrc
//localhost:15443/:always-auth = false
//localhost:15443/:email = "hasanuzzaman.sumon#gmail.com"
//localhost:15443/:username = "engr.hasanuzzaman"
; registry = "https://registry.npmjs.org/" (overridden)
From above you will see that project config indicating a .npmrc that is on my project's root folder.
In unix system file that start with . are hidden file. To see hidden file on unix you can use ctl+h of ls -a from terminal.
How to solve this problem
Remove registry = http://localhost:15443/ from .npmrc file if you don't need this
set registry option like following
npm install your_package --registry=https://registry.npmjs.org
It seems require init once again:
Go to package directory (where package.json is located)
Run: npm init
Answer all questions in command line
Go to browser and go 127.0.0.1:15443
As successful result should get: { error: "missing" }

npm install -g <package> error EADDRINUSE

I have been trying to install jshint through npm that is required for SublimeLinter-jshint.
I am running windows 7 (64bit). It seems to keep failing with the error message:
`C:\Users\Ephekz>npm install -g jshint
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\Program Files (x86)\nodejs\\node.exe" "C:\Program Files (
x86)\nodejs\node_modules\npm\bin\npm-cli.js" "install" "-g" "jshint"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! code EADDRINUSE
npm ERR! errno EADDRINUSE
npm ERR! syscall connect
npm ERR! connect EADDRINUSE
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! C:\Users\Ephekz\npm-debug.log`
I have tried this so far:
disabling AVG antivirus
disabling windows Firewall
checking if port 443 is in use by another service using netstat -aon : findstr:443. (nothing is listening in on that port)
tried different versions of nodejs v.5.6.0, v.4.3.0, v.0.1.24
tried multiple internet connections, also tried internet connection with no router
tried "npm cache clean"
tried "npm config set registry https://registry.npmjs.org/" and also "npm config set registry http://registry.npmjs.org/"
I have tried installing a different package (bower) which was successful.
I am not running through a proxy
I am not really sure what to do from here to make this work. Any suggestions would be greatly appreciated. I have attached a link to the debug log below:
https://github.com/npm/npm/files/133529/npm-debug.txt
In case anyone is experiencing a similar issue, I was able to resolve this issue by reinstalling the driver for my network adapter.

nodejs or meteor- how get it working on OVH Cloud VPS

I got problem using OVH CLOUD VPS and NodeJS / MeteorJS.
When trying to do meteor update I receive:
Unable to update package catalog (are you offline?)
If you are using Meteor behind a proxy, set HTTP_PROXY and HTTPS_PROXY environment variables or see this page for more details: https://github.com/meteor/meteor/wiki/Using-Meteor-behind-a-proxy
When trying do any npm install package I get:
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'
I have been googling for some time and all sollutions with making npm set registry or adding / deleting npm config (set / delete) proxy doesnt bring sollution.
Have any of you solved how to use NPM / METEOR on OVH VPS ?
similar question here:
npm not working - "read ECONNRESET"
answer I believe is:
npm config set registry http://registry.npmjs.org/
or https

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