运行此命令时,nodemon应用程序崩溃了,然后运行test-watch'

时间:2017-09-08 17:02:38

标签: node.js mocha nodemon

在我的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。

2 个答案:

答案 0 :(得分:3)

而不是单引号,为什么不通过转义它们来引入双引号。

试试这个:

"test-watch":"nodemon --exec \"npm test\""

答案 1 :(得分:0)

如果您使用的是Windows,请尝试在exec命令后删除单引号:

"test-watch": "nodemon --exec npm test"