试图运行黄瓜,但得到这个错误

时间:2018-01-29 22:10:07

标签: cucumber cucumberjs

我正在尝试使用javascript运行一些黄瓜测试,但我不断收到此错误。如果是,我是否需要更改执行路径,我该怎么办?我试图在本地和全球安装黄瓜,但它似乎没有得到解决

cucumber-js
    Error: 
          You appear to be executing an install of cucumber (most likely a global install)
          that is different from your local install (the one required in your support files).
          For cucumber to work, you need to execute the same install that is required in your support files.
          Please execute the locally installed version to run your tests.

          Executed Path: /usr/local/lib/node_modules/cucumber/lib/index.js
          Local Path:    /Users/chiragverma/node_modules/cucumber/lib/index.js

        at /usr/local/lib/node_modules/cucumber/lib/cli/install_validator.js:22:13
        at Generator.next (<anonymous>)
        at Generator.tryCatcher (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/util.js:16:23)
        at PromiseSpawn._promiseFulfilled (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/generators.js:97:49)
        at Promise._settlePromise (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/promise.js:574:26)
        at Promise._settlePromise0 (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/promise.js:614:10)
        at Promise._settlePromises (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/promise.js:693:18)
        at Async._drainQueue (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/async.js:133:16)
        at Async._drainQueues (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/async.js:143:10)
        at Immediate.Async.drainQueues (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/async.js:17:14)
        at runCallback (timers.js:789:20)
        at tryOnImmediate (timers.js:751:5)
        at processImmediate [as _immediateCallback] (timers.js:722:5)
    Chirags-MacBook-Air:test chiragverma$ sudo cp /Users/chiragverma/ /usr/local/lib/
    Password:
    Sorry, try again.
    Password:
    cp: /Users/chiragverma/ is a directory (not copied).
    Chirags-MacBook-Air:test chiragverma$ cucumber-js
    Error: 
          You appear to be executing an install of cucumber (most likely a global install)
          that is different from your local install (the one required in your support files).
          For cucumber to work, you need to execute the same install that is required in your support files.
          Please execute the locally installed version to run your tests.

          Executed Path: /usr/local/lib/node_modules/cucumber/lib/index.js
          Local Path:    /Users/chiragverma/node_modules/cucumber/lib/index.js

        at /usr/local/lib/node_modules/cucumber/lib/cli/install_validator.js:22:13
        at Generator.next (<anonymous>)
        at Generator.tryCatcher (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/util.js:16:23)
        at PromiseSpawn._promiseFulfilled (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/generators.js:97:49)
        at Promise._settlePromise (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/promise.js:574:26)
        at Promise._settlePromise0 (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/promise.js:614:10)
        at Promise._settlePromises (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/promise.js:693:18)
        at Async._drainQueue (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/async.js:133:16)
        at Async._drainQueues (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/async.js:143:10)
        at Immediate.Async.drainQueues (/usr/local/lib/node_modules/cucumber/node_modules/bluebird/js/release/async.js:17:14)
        at runCallback (timers.js:789:20)
        at tryOnImmediate (timers.js:751:5)
        at processImmediate [as _immediateCallback] (timers.js:722:5)
    Chirags-MacBook-Air:test chiragverma$ sudo cp /Users/chiragverma /usr/local/lib
    cp: /Users/chiragverma is a directory (not copied).

2 个答案:

答案 0 :(得分:0)

您可以查看本地和全球版本的Cucumber,可能如果它们不同,您会看到此错误

答案 1 :(得分:0)

您需要在.vscode / launch.json中指定cwd,如下所示:

"cwd": "${workspaceRoot}"

整个样子,

"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "cwd": "${workspaceRoot}",
        "program": "${workspaceRoot}/node_modules/protractor/bin/protractor",
        "stopOnEntry": false,
        "args": [
            "${workspaceRoot}/config/config.js"
        ],
    }
]

我遇到了类似的问题,我得到了from github forum的解决方案