尝试使用npm安装软件包时出错

时间:2014-07-01 07:37:54

标签: node.js cmd npm

当我尝试使用npm安装任何软件包或只安装npm install时,我会得到一个错误列表 不知道该怎么做

C:\Users\Dhayalan\Documents\app>npm install
npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open 'C:\Users\Dhayalan\Documents\app\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 "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\Users\Dhayalan\Documents\app
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path C:\Users\Dhayalan\Documents\app\package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\Users\Dhayalan\Documents\app\npm-debug.log
npm ERR! not ok code 0

C:\Users\Dhayalan\Documents\app>

1 个答案:

答案 0 :(得分:1)

您的包没有package.json个文件。有两种情况可能会发生此错误:

  • npm install:安装package.json
  • 中定义的所有软件包
  • npm install packagename --save安装包并将其作为依赖项添加到package.json

只做npm install packagename应始终正常。您可以通过运行package.json来创建npm init