簡體   English   中英

npm run在嘗試運行腳本時總是會出錯

[英]npm run always gives error when trying to run scripts

我有NPM的問題。 最近,每當我嘗試使用npm運行腳本時,它就會給我一大堆錯誤,即使我知道腳本是正確的,我也無法弄清楚為什么......

的package.json

{
  "name": "testing",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

正如你所看到的那樣,這只是在運行npm init之后生成的,只是輸入了幾次......然而當我運行npm run test我得到了這個......

> testing@1.0.0 test C:\Users\user\Desktop\testing
> echo "Error: no test specified" && exit 1

"Error: no test specified"

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "test"
npm ERR! node v7.4.0
npm ERR! npm  v4.1.2
npm ERR! code ELIFECYCLE
npm ERR! testing@1.0.0 test: `echo "Error: no test specified" && exit 1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testing@1.0.0 test script 'echo "Error: no test specified" && exit 1'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the testing package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     echo "Error: no test specified" && exit 1
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs testing
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls testing
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\user\Desktop\testing\npm-debug.log

正如您在錯誤消息中看到的那樣,我有節點v7.4.0和npm v4.1.2 ...之前我運行的是節點v6.9.2,但是我在收到此錯誤后仍然更新但仍然沒有更改......我也不知道知道它是否重要,但我正在運行Windows 10.我已經嘗試了npm cache clear解決方案,但這對我不起作用。

這是正常的,當你運行npm run test ,它會在package.json執行相應的腳本,所以這一行

"test": "echo \"Error: no test specified\" && exit 1"

如您所見,它會引發錯誤並退出,狀態代碼不是0( exit 1 ),這是一個錯誤代碼。

您必須通過其他真正運行測試的內容來更改測試腳本。

暫無
暫無

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

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