【问题标题】:npm run test error Node.jsnpm 运行测试错误 Node.js
【发布时间】:2018-07-06 13:12:16
【问题描述】:

我正在使用 node.js 制作一个 API,并想测试一些文件。 npm init 运行良好并正确安装了软件包,例如 mongooseexpress。但是,当我运行npm run test-watch 时,终端会抛出以下错误:

[nodemon] 1.14.11
[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...

以下是 package.json 文件的内容:

"scripts": {
    "test": "mocha server/**/*.test.js",
    "test-watch": "nodemon --exec 'npm test'"
  }

节点路径被添加到用户路径中。 init 成功运行并安装了软件包。所以我想知道语法有没有错误。

注意:如果您想检查任何代码,请告诉我

【问题讨论】:

标签: node.js mongodb express node-modules nodemon


【解决方案1】:

这是因为我使用的是 Windows 操作系统,语法有错误:

"test-watch": "nodemon --exec 'npm test'"

上面的代码应该如下:

"test-watch": "nodemon --exec \"npm test\""

【讨论】:

    猜你喜欢
    • 2014-06-10
    • 1970-01-01
    • 2019-04-20
    • 2022-08-09
    • 2021-12-03
    • 2016-07-19
    • 2017-09-07
    • 2018-07-21
    • 2018-10-30
    相关资源
    最近更新 更多