【发布时间】:2018-06-14 17:19:06
【问题描述】:
我想让我的 package.json 能够在带有 npm 5.5.1 的 Windows 10 上使用命令 npm run test-watch 运行。在我的 package.json 中:
"scripts": {
"test": "mocha server/**/*.test.js",
"test-watch": "nodemon --exec 'npm test'"
}
但是,我奇怪地将代码解释为其中有一个单引号。我实际上正在学习 Udemy 课程,因此它似乎对讲师有用。但是,这是我得到的输出:
PS D:\courses\node-course\node-todo-api> npm run test-watch
> todo-api@1.0.0 test-watch D:\courses\node-course\node-todo-api
> nodemon --exec 'npm test'
[nodemon] 1.14.7
[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...
我需要进行哪些更改才能使其正常工作?它似乎保留了字符串上的引号。我似乎无法绕过它。当我直接运行命令时,它可以工作:
PS D:\courses\node-course\node-todo-api> nodemon --exec 'npm test'
[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `npm test`
> todo-api@1.0.0 test D:\courses\node-course\node-todo-api
> mocha server/**/*.test.js
started on port 3000
Post /todos
√ should create a new todo (50ms)
1 passing (1s)
【问题讨论】:
标签: node.js npm package.json nodemon