不使用 npm 无法运行节点命令

时间:2021-01-03 23:53:02

标签: node.js npm

我正在 Windows 机器上开发一个新的节点项目。

在我的 package.json 中,我设置了测试脚本:

"scripts": {
    "test": "cucumber-js test"
  },

如果我运行命令 > npm run test 它可以正常工作,但是如果我运行 > cucumber-js test 我得到以下错误:

cucumber-js : The term 'cucumber-js' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify 
that the path is correct and try again.
At line:1 char:1
+ cucumber-js test
+ ~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (cucumber-js:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

有什么解释吗?我该如何解决?

1 个答案:

答案 0 :(得分:0)

正如评论中提到的,通过提供确切的路径来解决问题:.\node_modules\.bin\cucumber-js test

相关问题