Node.js   发布时间:2022-04-24  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了node.js – npm run在尝试运行脚本时总是会出错大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我有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缓存清除解决方案,但这对我不起作用.

解决方法

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

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

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

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

大佬总结

以上是大佬教程为你收集整理的node.js – npm run在尝试运行脚本时总是会出错全部内容,希望文章能够帮你解决node.js – npm run在尝试运行脚本时总是会出错所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。