簡體   English   中英

觸發“ npm install”時,nodejs無法讀取依賴項

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

我收到以下錯誤。

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命令安裝用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時,它將安裝依賴項express jade和cookie-parser,您將收到此錯誤,因為您沒有package.json,因此,如果要安裝不帶package.json的軟件包,則必須編寫:npm install express npm install jade npm安裝cookie解析器

從得到的錯誤類型可以肯定,您在鍵入npm install的目錄中沒有package.json文件。 您應該首先使用npm init來創建必要的package.json文件,然后鍵入npm install

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM