nodejs触发“npm install”时无法读取依赖项

时间:2014-11-21 05:15:48

标签: angularjs node.js git

我收到以下错误。

D:\Ashley\nodejs>npm install
npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open 'D:\Ashley\nodejs\package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "D:\\Ashley\\nodejs\\\\node.exe" "D:\\Ashley\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd D:\Ashley\nodejs
npm ERR! node -v v0.10.33
npm ERR! npm -v 1.4.28
npm ERR! path D:\Ashley\nodejs\package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     D:\Ashley\nodejs\npm-debug.log
npm ERR! not ok code 0

2 个答案:

答案 0 :(得分:0)

npm install命令安装用package.json文件编写的节点包,例如你有package.json:

{
    "name": "application-name"
  , "version": "0.0.1",
  "main": "app.js"
  , "dependencies": {
      "express": "*"
    , "jade": "*"
    ,"cookie-parser":"*"
  },
  "scripts": {
    "start": "node app.js"
  }
}

当你编写npm install时,它会安装依赖表达jade和cookie-parser 你收到这个错误,因为你没有package.json所以如果你想安装没有package.json的这个包,你必须写: npm安装快递 npm安装玉器 npm install cookie-parser

答案 1 :(得分:0)

根据您收到的错误类型,您可以确定在您键入npm install 的目录中没有package.json文件。 您应首先使用npm init创建必要的package.json文件,然后键入npm install