2

I am trying to execute a small example of automated test using Webstorm, cucumber and protractor. I have already installed cucumber using this command within the root of the project:

sudo npm install -g cucumber

I have already created the conf.js file and when running this command within the prompt:

> protractor conf.js

Finally, the output is: *

[13:13:18] E/launcher - Error: Error: Cannot find module 'cucumber'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.module.exports.load (/Users/alfredo.bazo/node_modules/protractor-cucumber-framework/lib/cucumberLoader.js:19:24)
    at Object.<anonymous> (/Users/alfredo.bazo/node_modules/protractor-cucumber-framework/index.js:8:33)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
[13:13:18] E/launcher - Process exited with error code 100

I have no idea what else I can do, any suggestions?

Dominik
  • 1,016
  • 11
  • 30
Alfredo Bazo Lopez
  • 323
  • 1
  • 4
  • 12
  • To add Cucumber as a development dependency, use Try `npm install --save-dev cucumber` - see the [docs](https://docs.cucumber.io/installation/javascript/) – Marit Aug 02 '18 at 13:22
  • Possible duplicate of [I receive the error: cannot find module 'cucumber' when executing Protractor](https://stackoverflow.com/questions/28632398/i-receive-the-error-cannot-find-module-cucumber-when-executing-protractor) – Marit Aug 02 '18 at 13:22
  • Try searching for similar questions, and/or Googling for the error message – Marit Aug 02 '18 at 13:23

2 Answers2

2

There are two approach to resolve your problem, and recommend to use approach 1).

1) install cucumber as project local package, rather than global package.

npm install -S cucumber

2) install cucumber as global package, and you need to add below Environment variable to tell node.exe where to find and load global package.

NODE_PATH=<npm global package install folder path on your machine>

you can execute npm config get prefix which will print out the global package install folder path.

Important: After add environment variable, you need to try in new opened cmd/terminal window.

yong
  • 13,357
  • 1
  • 16
  • 27
0

how to overcome this :try to share video please regarding this query : ...

install cucumber as global package, and you need to add below Environment variable to tell node.exe where to find and load global package.

NODE_PATH= you can execute npm config get prefix which will print out the global package install folder path.

Important: After add environment variable, you need to try in new opened cmd/terminal window.