单引号在 package.json 中不起作用
single quotes not working in package.json
我想让我的 package.json 能够 运行 使用命令 npm 运行 test-watch on Windows 10 with npm 5.5.1 .在我的 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)
不幸的是,在使用 npm 时,操作系统和 shell 可能会让人头疼。有些东西在一台电脑上工作,有些在另一台电脑上工作。
虽然这两个都应该在 Windows 10 上工作:
"test-watch": "nodemon --exec \"npm test\""
"test-watch": "nodemon --exec npm test"
我想让我的 package.json 能够 运行 使用命令 npm 运行 test-watch on Windows 10 with npm 5.5.1 .在我的 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)
不幸的是,在使用 npm 时,操作系统和 shell 可能会让人头疼。有些东西在一台电脑上工作,有些在另一台电脑上工作。
虽然这两个都应该在 Windows 10 上工作:
"test-watch": "nodemon --exec \"npm test\""
"test-watch": "nodemon --exec npm test"