nodemon''mocha'未被识别为内部或外部命令,可操作程序或批处理文件

MTo*_*oma 10 mocha.js node.js nodemon

使用package.json中的行为Windows 10上的nodejs项目运行测试:

"test": "nodemon --exec 'mocha -R min'"
Run Code Online (Sandbox Code Playgroud)

我明白了:

>  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...
Run Code Online (Sandbox Code Playgroud)

MTo*_*oma 31

这行很好用:

"test": "nodemon --exec \"mocha -R min\""
Run Code Online (Sandbox Code Playgroud)

在package.json中

  • 谢谢..为什么第一种语法只适用于某些人? (2认同)
  • 它是 Windows 唯一的问题 (2认同)

小智 7

全局安装 mocha 然后它就可以工作了

npm install -g mocha --save-dev


小智 5

如果您使用的是 Windows 操作系统,请不要使用单引号

"test": "nodemon --exec 'mocha -R min'"

用这个

"test": "nodemon --exec mocha -R min"

访问:www.mycodingx.com 了解更多