在服务器中找不到模块'async'

时间:2016-08-30 05:14:00

标签: node.js npm-install

我正在linux服务器上部署我的nodejs项目。尝试运行我的nodejs时遇到以下错误。

Cannot find module 'async' in server.

我无法找出原因。谁能告诉我我必须做的事情。

的package.json

{
  "name": "works",
  "version": "0.0.0",
  "main": "server.js",
  "dependencies": {
    "async": "^1.2.1",
    "bcrypt-nodejs": "0.0.3",
    "bcryptjs": "^2.1.0",
    "body-parser": "^1.13.1",
    "colors": "^1.1.2",
    "cors": "^2.7.1",
    "express": "^4.13.0",
    "jwt-simple": "^0.3.0",
    "moment": "^2.10.3",
    "mongoose": "^4.0.6",
    "morgan": "^1.6.0",
    "jsonwebtoken": "^5.7.0",
    "request": "^2.58.0"
  }
}
安装npm install

。我收到以下错误:

npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/bcrypt-nodejs/0.0.3
npm http GET https://registry.npmjs.org/bcryptjs
npm http GET https://registry.npmjs.org/body-parser
npm http GET https://registry.npmjs.org/colors
npm http GET https://registry.npmjs.org/cors
npm http GET https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/jwt-simple
npm http GET https://registry.npmjs.org/moment
npm http GET https://registry.npmjs.org/mongoose
npm http GET https://registry.npmjs.org/morgan
npm http GET https://registry.npmjs.org/jsonwebtoken
npm http GET https://registry.npmjs.org/request

npm ERR! Error: failed to fetch from registry: colors
npm ERR!     at /usr/share/npm/lib/utils/npm-registry-    client/get.js:139:12
npm ERR!     at cb (/usr/share/npm/lib/utils/npm-registry- client/request.js:31:9)
npm ERR!     at Request._callback (/usr/share/npm/lib/utils/npm- registry-client/request.js:136:18)
npm ERR!     at Request.callback ( /usr/lib/nodejs/request/main.js:119:22)
npm ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
npm ERR!     at Request.emit (events.js:88:20)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
npm ERR!     at ClientRequest.g (events.js:156:14)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
npm ERR! You may report this log at:
npm ERR!     <http://bugs.debian.org/npm>
npm ERR! or use
npm ERR!     reportbug --attach /home/siva/www/emoheal.com/emoheal/npm-  debug.log npm
npm ERR! 
npm ERR! System Linux 3.5.0-17-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! cwd /home/siva/www/emoheal.com/emoheal
npm ERR! node -v v0.6.19
npm ERR! npm -v 1.1.4
npm ERR! message failed to fetch from registry: colors
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/siva/www/emoheal.com/emoheal/npm-debug.log
npm not ok
  

我的debug.log错误

info it worked if it ends with ok
verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'install', 'async' ]
info using npm@1.1.4
info using node@v0.6.19
verbose config file /home/siva/.npmrc
verbose config file /usr/etc/npmrc
verbose config file /usr/share/npm/npmrc
verbose caching /home/siva/www/emoheal.com/emoheal/package.json
verbose loadDefaults emoheal@0.0.0
verbose from cache /home/siva/www/emoheal.com/emoheal/package.json
verbose readDependencies: using package.json deps
verbose cache add [ 'async@^1.2.1', null ]
silly cache add: name, spec, args [ undefined, 'async@^1.2.1', [    'async@^1.2.1', null ] ]
verbose parsed url { pathname: 'async@^1.2.1',verbose parsed url   path: 'async@^1.2.1',verbose parsed url   href: 'async@^1.2.1' }
silly cache add: name, spec, args [ 'async', '^1.2.1', [ 'async',    '^1.2.1' ] ]
verbose parsed url { pathname: '^1.2.1', path: '^1.2.1', href: '^1.2.1'  }
verbose addNamed [ 'async', '^1.2.1' ]
verbose addNamed [ null, null ]
info addNameTag [ 'async', '^1.2.1' ]
verbose raw, before any munging async
verbose url resolving [ 'https://registry.npmjs.org/', './async' ]
verbose url resolved https://registry.npmjs.org/async
http GET https://registry.npmjs.org/async
ERR! Error: failed to fetch from registry: async
ERR!     at /usr/share/npm/lib/utils/npm-registry-client/get.js:139:12
ERR!     at cb (/usr/share/npm/lib/utils/npm-registry- client/request.js:31:9)
ERR!     at Request._callback (/usr/share/npm/lib/utils/npm-registry-client/request.js:136:18)
ERR!     at Request.callback (/usr/lib/nodejs/request/main.js:119:22)
ERR!     at Request.<anonymous> (/usr/lib/nodejs/request/main.js:212:58)
ERR!     at Request.emit (events.js:88:20)
ERR!     at ClientRequest.<anonymous> (/usr/lib/nodejs/request/main.js:412:12)
ERR!     at ClientRequest.g (events.js:156:14)
ERR!     at ClientRequest.emit (events.js:67:17)
ERR!     at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1256:7)
ERR! You may report this log at:
ERR!     <http://bugs.debian.org/npm>
ERR! or use
ERR!     reportbug --attach /home/siva/www/emoheal.com/emoheal/npm- debug.log npm
ERR! 
ERR! System Linux 3.5.0-17-generic
ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "async"
ERR! node -v v0.6.19
ERR! npm -v 1.1.4
ERR! message failed to fetch from registry: async
verbose exit [ 1, true ]

2 个答案:

答案 0 :(得分:2)

猜猜你在谈论这个: https://www.npmjs.com/package/async

你必须先安装它, npm install async 比它在你的node_modules文件夹中,你可以要求它。

答案 1 :(得分:-1)

进入项目文件夹并运行:

npm install

此命令安装package.json

中的所有项目依赖项