【发布时间】:2018-02-17 16:06:24
【问题描述】:
在我的 package.json 文件中,我写了这个运行 nodemon:"scripts": {
"test": "mocha server/**/*.test.js",
"test-watch": "nodemon --exec 'npm test'"
},
这个错误显示在终端:
> node-todo-api@1.0.0 test-watch D:\nodepractice\node-todo-api
> nodemon --exec 'npm test'
[nodemon] 1.12.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `'npm test'`
''npm' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...
这个问题怎么解决,我想用nodemon。
【问题讨论】:
-
如果手动运行 npm test 是否也会出现同样的错误?
-
当我运行这个 npm 测试 > node-todo-api@1.0.0 test D:\nodepractice\node-todo-api > mocha server/**/*.test.js 警告:可能找不到任何匹配模式的测试文件:server/**/*.test.js 找不到测试文件 npm ERR!测试失败。有关更多详细信息,请参见上文。 @jmcgui05
-
您能否更新上述代码以包含完整的 package.json,或者至少包含脚本所在的位置?
-
已更新但输出仍然相同
-
手动运行 npm test 时出现的错误表明测试目录不在应有的位置。当 nodemon 在 npm test 上失败时出现的错误表明 npm 未在全局范围内正确安装,或者 nodemon 无权访问它。