单引号在package.json中不起作用

时间:2018-01-04 22:16:48

标签: node.js npm package.json nodemon

我想让我的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)

1 个答案:

答案 0 :(得分:6)

不幸的是,操作系统和shell在使用npm时会引起很大的麻烦。有些东西在一台计算机上运行,​​有些在另一台计算机上运行。

这两个应该适用于Windows 10:

from designer_file import Ui_Gui  # Designer file is the converted .ui file and Ui_Gui is the ui class it created

class GUIWindow(QtWidgets.QWidget, Ui_Gui):

    def __init__(self):
        QtWidgets.QWidget.__init__(self)
        self.setupUi(self)  # This is necessary to setup the ui when using this method
        # Code here...
相关问题