3

I am trying to run some cucumber tests with javascript but I keep getting this error. Do i need to change my execute path if yes, how can i do it? I have tried to install cucumber locally and globally but it does not seem to get resolved

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).
J Don
  • 65
  • 1
  • 2
  • 6

3 Answers3

3

You need to specify the cwd in your .vscode/launch.json as following:

"cwd": "${workspaceRoot}"

Entire would be like,

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

I had a similar problem, the solution I got from github forum

Harshal
  • 485
  • 7
  • 16
0

I find myself visiting this page a year and a half after I upvoted @Sol's answer above. I realise that this is no doubt a result of my local environment setup, but it could help someone else...

After running some commands in Powershell I ran my tests and got the error message in the OP's question. The tests ran fine from a Powershell terminal in VS Code. This is almost certainly because the configuration in the launch.json file is required.

user1007074
  • 2,093
  • 1
  • 18
  • 22
-1

Can you check your local and Global version of Cucumber, probably if they are different you will see this error

Mukul
  • 1
  • 1