【问题标题】:sh: 1: cucumber.js: not foundsh: 1: cucumber.js: 未找到
【发布时间】:2019-01-28 19:02:04
【问题描述】:
在这里尝试使用本教程:
https://github.com/lykmapipo/nodejs-cucumber-sample
nvm current 的输出是:v10.12.0。
npm --version 的输出是:6.4.1>
一旦我调用npm test,就会出现以下错误:
> nodejs-cucumber-sample@0.0.1 test /home/gnuc/code/nodejs-cucumber-sample
> cucumber.js
sh: 1: cucumber.js: not found
我不确定为什么会这样。 $PATH 包括 /home/gnuc/.nvm/versions/node/v10.12.0/bin。而且我已经用过npm install cucumber -g和npm install cucumber
【问题讨论】:
标签:
node.js
npm
cucumber
nvm
【解决方案1】:
确保您的 package.json 文件包含以下内容:"test": "cucumber-js"
所以它看起来像这样:
{
"name": "hellocucumber",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": **"cucumber-js"**
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"cucumber": "^5.1.0"
}
}
【解决方案2】:
因此,您需要实际调用 npm 包/库。我在 package.json 中定义了以下内容:
"scripts": {
"test": "node ./node_modules/.bin/cucumber-js"
},
您还可以在此调用中添加一些 --- 标签。
"scripts": {
"test": "node ./node_modules/.bin/cucumber-js --tags @RegressionTestSuite"
},
这将运行任何顶部有@RegressionTestSuite 的功能文件
另外,我创建了一个带有时间戳的输出/结果文件。
"scripts": {
"test": "node ./node_modules/.bin/cucumber-js --tags @RegressionTestSuite --format json:./results/log_new_`date +%Y-%m-%m__%H-%M`.json""
},
我希望这会有所帮助。
【解决方案3】:
节点./node_modules/cucumber/bin/cucumber-js
此命令运行良好。
你得到了 sh:1: cucumber.js: not found 错误意味着首先请查看 cucumber.js 的路径