简体   繁体   中英

Error in installing express either using package.json file or without using package.json file

I am trying to install express in my windows terminal by following the instruction mentioned in express website guide

1 First I created a directory node and inside that package.json file.

my package.json is as follows

{
  "name": "hello-world",
  "description": "hello world test app",
  "version": "0.0.1",
  "private": true,
  "dependencies": {
    "express": "3.x"
  }
}

then I tried to run the command

npm install

but getting the following error

E:\myFindings\nodejs_programs\node>npm install
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/express/-/express-3.4.8.tgz
npm ERR! Error: tunneling socket could not be established, cause=connect ETIMEDOUT
npm ERR!     at ClientRequest.onError (C:\Program Files\nodejs\node_modules\npm\node_modules\request\tunnel.js:161:17)
npm ERR!     at ClientRequest.g (events.js:185:14)
npm ERR!     at ClientRequest.EventEmitter.emit (events.js:88:17)
npm ERR!     at Socket.socketErrorListener (http.js:1320:9)
npm ERR!     at Socket.EventEmitter.emit (events.js:88:17)
npm ERR!     at Socket._destroy.self.errorEmitted (net.js:329:14)
npm ERR!     at process.startup.processNextTick.process._tickCallback (node.js:244:9)
npm ERR!  { [Error: tunneling socket could not be established, cause=connect ETIMEDOUT] code: 'ECONNRESET' }
npm ERR! 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.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 E:\myFindings\nodejs_programs\node
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! code ECONNRESET
npm ERR! message tunneling socket could not be established, cause=connect ETIMEDOUT
npm ERR! Error: socket hang up
npm ERR!     at createHangUpError (http.js:1253:15)
npm ERR!     at Socket.socketCloseListener (http.js:1304:23)
npm ERR!     at Socket.EventEmitter.emit (events.js:88:17)
npm ERR!     at Socket._destroy.destroyed (net.js:358:10)
npm ERR!     at process.startup.processNextTick.process._tickCallback (node.js:244:9)
npm ERR!  { [Error: socket hang up] code: 'ECONNRESET' }
npm ERR! 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.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 E:\myFindings\nodejs_programs\node
npm ERR! node -v v0.8.0
npm ERR! npm -v 1.1.32
npm ERR! code ECONNRESET
npm ERR! message socket hang up
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     E:\myFindings\nodejs_programs\node\npm-debug.log
npm ERR! not ok code 0

I am unable to understand what is the problem, please help me to sort out

I even try to install express without using the .json file but getting the same error

contents of my npm config list

E:\myFindings\nodejs_programs\node>npm config list
; cli configs

; userconfig C:\Users\sudipkumars\.npmrc
https-proxy = "http://sudip:sudip7@proxy:8086/"
proxy = "http://sudip:sudip7@proxy:8086/%20strict-ssl%20=%20false"
registry = "https://registry.npmjs.org/"

; builtin config C:\Program Files\nodejs\node_modules\npm\npmrc
prefix = "C:\\Users\\sudipkumars\\AppData\\Roaming\\npm"

; node install prefix = C:\Program Files
; node bin location = C:\Program Files\nodejs\\node.exe
; cwd = E:\myFindings\nodejs_programs\node
; HOME = C:\Users\sudipkumars
; 'npm config ls -l' to show all defaults.

I tried your suggestion

npm config set registry http://registry.npmjs.org/

and output is

E:\myFindings\nodejs_programs\node>npm install express
npm http GET http://registry.npmjs.org/express
npm http 304 http://registry.npmjs.org/express
npm http GET http://registry.npmjs.org/express/-/express-3.4.8.tgz
npm ERR! Error: getaddrinfo ENOENT
npm ERR!     at errnoException (dns.js:31:11)
npm ERR!     at Object.onanswer [as oncomplete] (dns.js:123:16)
npm ERR!  { [Error: getaddrinfo ENOENT] code: 'ENOTFOUND', errno: 'ENOTFOUND', syscall: 'getaddrinfo' }
npm ERR! 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>

In terms of understanding the issue. The problem lies with your computer not being able to establish a connection with: https://registry.npmjs.org/express/-/express-3.4.8.tgz

It is attempting to use the HTTP GET Method to retrieve the file from the server at the NPM registry but it seems it is timing out:

npm http GET https://registry.npmjs.org/express/-/express-3.4.8.tgz
npm ERR! Error: tunneling socket could not be established, cause=connect ETIMEDOUT

This could be for a few reasons but I'll mention two main causes:

  1. Downtime at npmjs.org, easily checked with http://status.npmjs.org/
  2. You're behind a proxy preventing this

Looking at your npm config:

  • Unless you have a proxy setup called proxy then this won't work. So clear the proxy variables set
  • Set strict SSL to false using npm config set strict-ssl false
  • If these two don't work, attempt to set the registry to use a non encrypted connection using npm config set registry http://registry.npmjs.org/

I solved this issue by issuing the following commands

npm config set proxy false
npm cache clean

运行以下命令

npm install express

解决方法: npm config set registry= http://registry.npmjs.org/效果很好。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM