在Windows 10上运行Node.js项目的test,需要在package.json中添加以下行:
"test": "nodemon --exec 'mocha -R min'"
我得到:
> nodemon --exec 'mocha -R min'
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `'mocha -R min'`
''mocha' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...
rs
[nodemon] starting `'mocha -R min'`
''mocha' is not recognized as an internal or external command,
operable program or batch file.
[nodemon] app crashed - waiting for file changes before starting...
mocha
(而不是使用nodemon
)而搜索错误消息并来到这里,我在 Windows 上也遇到了这个问题,尽管我已经运行了npm i
。我不得不再次显式地运行npm i -D mocha
,然后它就可以工作了。 - Neo