当前位置:  开发笔记 > 编程语言 > 正文

npm run在尝试运行脚本时总是会出错

如何解决《npmrun在尝试运行脚本时总是会出错》经验,为你挑选了1个好方法。

我有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解决方案,但这对我不起作用.



1> ThomasThieba..:

这是正常的,当你运行时npm run test,它会执行相应的脚本package.json,所以这一行

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

如您所见,它会引发错误并退出,状态代码不是0(exit 1),这是一个错误代码.

您必须通过其他真正运行测试的内容来更改测试脚本.

推荐阅读
谢谢巷议
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有