简体   繁体   English

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

[英]nodejs Couldn't read dependencies when triggering “npm install”

I'm getting the below error. 我收到以下错误。

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

npm install command installs node packages wich are written in package.json file for example you have package.json : 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"
  }
}

when you write npm install it will install dependencies express jade and cookie-parser you recieve this error because you have no package.json so if you want to install this packages without package.json you have to write: npm install express npm install jade npm install cookie-parser 当您编写npm install时,它将安装依赖项express jade和cookie-parser,您将收到此错误,因为您没有package.json,因此,如果要安装不带package.json的软件包,则必须编写:npm install express npm install jade npm安装cookie解析器

It is certain from the type of error you get that you do not have a package.json file at the directory in which you type npm install . 从得到的错误类型可以肯定,您在键入npm install的目录中没有package.json文件。 You should first use npm init which creates the necessary package.json file and then type npm install . 您应该首先使用npm init来创建必要的package.json文件,然后键入npm install

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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