0

I want to learn node and express js. I installed nodejs perfectly in office and trying to intall expressjs using ' npm install express --g ' , But it is throwing error. I done some proxy setting also using ' npm config set proxy http://autoproxyfh.xxxx.com/VPN-US.pac:80 ' and ' npm config set proxy http://username:password@http://autoproxyfh.xxxx.com/VPN-US.pac:80 ' . But still it is throwing error. Please find the error below.

C:\Users\user\Desktop\Nodejs>npm install express --g npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\Node.js\node.exe" "C:\Program Files\Node.js \node_modules\npm\bin\npm-cli.js" "install" "express" "--g" npm ERR! node v6.4.0 npm ERR! npm v3.10.3 npm ERR! code ECONNRESET

npm ERR! network tunneling socket could not be established, cause=connect ECONNR EFUSED 10.220.81.10:80 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'

npm ERR! Please include the following file with any support request: npm ERR! C:\Users\RaviKanth.Yandluri\Desktop\Nodejs\npm-debug.log

and tried with another possibility but still throwing error.

C:\Users\user\Desktop\Nodejs>npm config set registry http://regist ry.npmjs.org/

C:\Users\user\Desktop\Nodejs>npm install express npm ERR! Windows_NT 6.1.7601 npm ERR! argv "C:\Program Files\Node.js\node.exe" "C:\Program Files\Node.js \node_modules\npm\bin\npm-cli.js" "install" "express" npm ERR! node v6.4.0 npm ERR! npm v3.10.3 npm ERR! code ECONNREFUSED npm ERR! errno ECONNREFUSED npm ERR! syscall connect

npm ERR! Error: connect ECONNREFUSED 10.1.2.50:80 npm ERR! at Object.exports._errnoException (util.js:1026:11) npm ERR! at exports._exceptionWithHostPort (util.js:1049:20) npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1081:14) npm ERR! { Error: connect ECONNREFUSED 10.1.2.50:80 npm ERR! at Object.exports._errnoException (util.js:1026:11) npm ERR! at exports._exceptionWithHostPort (util.js:1049:20) npm ERR! at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1081:14) npm ERR! code: 'ECONNREFUSED', npm ERR! errno: 'ECONNREFUSED', npm ERR!
syscall: 'connect', npm ERR! address: '10.1.2.50', npm ERR! port: 80 } 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! C:\Users\user\Desktop\Nodejs\npm-debug.log

RKCY
  • 4,095
  • 14
  • 61
  • 97
  • You don't need to install express globally, you install it for a specific project (without the `-g` flag). What you can install globally is the [express-generator](https://expressjs.com/en/starter/generator.html) to help you get started. – nem035 Aug 29 '16 at 16:22
  • even though it is throwing same error. – RKCY Aug 29 '16 at 16:25
  • Have you tried any of these solutions: [question 1](http://stackoverflow.com/questions/18419144/npm-not-working-read-econnreset), [question 2](http://stackoverflow.com/questions/29395793/cant-install-anything-with-npm-econnreset-without-proxy) ? – nem035 Aug 29 '16 at 16:28
  • yes, tried but throwing error again. updated error in question – RKCY Aug 29 '16 at 16:32

2 Answers2

2

The proxy you have configured looks a little odd to me. Are you purposely including the http:// twice? You currently have the following:

npm config set proxy http://username:password@http://autoproxyfh.xxxx.com/VPN-US.pac:80

where I would expect

npm config set proxy http://username:password@autoproxyfh.xxxx.com/VPN-US.pac:80

I don't know for certain if that would effect anything, but I am behind an ssl inspecting proxy and have mine configured with http://user:pwd@proxyadd:80

Another thing to try would be to open the VPN-US.pac in a browser and check what proxy address it is sending your traffic through and use that directly, instead of using the pac.

The other things to note are if you are behind an ssl-inspecting proxy you will need to get the root certificates your organisation is using and add them to your key store, and tell npm to use the keystore with

npm config set cafile "cafilepath"
bpilling
  • 183
  • 9
0

ECONNREFUSED errors usually happen when you are behind a proxy. It could also be happening due to network firewall misconfiguration at your office. I suggest having a chat with your IT administrator and getting them to check if npm registry is blocked by any chance.

After your network issues are fixed, you don't need to install express globally using -g flag. You need to do the following to setup a project folder inside which you can install express:

mkdir myapp
cd myapp

Initialize NPM project:

npm init

Answer a series of simple questions that will generate your package.json file, then try installing express locally inside the project.

npm install express --save
ryder
  • 897
  • 6
  • 15
  • C:\Users\usernmae\Desktop\Nodejs>npm init This utility will walk you through creating a package.json file. It only covers the most common items, and tries to guess sensible defaults. See `npm help json` for definitive documentation on these fields and exactly what they do. Use `npm install --save` afterwards to install a package and save it as a dependency in the package.json file. Press ^C at any time to quit. name: (Nodejs) npm install express --save Sorry, name can only contain URL-friendly characters. name: (Nodejs) – RKCY Sep 01 '16 at 14:36
  • the above message is showed when use npm init command after npm install express --save command. – RKCY Sep 01 '16 at 14:37
  • Did you go into you project directory and run npm init utility? It will give you a simple series of questions to set up your package.json file. Finish that and after it you can install express in the same directory. – ryder Sep 01 '16 at 14:47
  • npm init runs first, then answer questions, then run npm install express --save. It's what I've written above as well. I see that you also got a warning for non url-friendly name of project.. So, you also need to give some suitable name for the app, like "my-app" or "nodejs-project". Just follow the hints the npm init utility gives you. – ryder Sep 01 '16 at 14:52
  • :- i created new folder called "node-project" and called ' npm init'. Json is created in the projct folder. after that installed express using ' npm install express ' . but it is also thrown error " npm ERR! Error: connect ECONNREFUSED 10.220.161.16:80 ". – RKCY Sep 01 '16 at 15:10
  • 1
    Ravi, you are facing the same proxy/network issue as mentioned above. You need to discuss that with the IT administrator at your office. It's possible there is a firewall or proxy that is blocking access to npm registry. It's not a problem with npm itself. You need to get them to fix the network issue first, before you can run npm commands. – ryder Sep 01 '16 at 15:34