首页 > 解决方案 > 不使用 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

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

标签: node.jsnpm

解决方案


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


推荐阅读