4
votes

I have found some posts describing the steps for setting this up but when I follow them I receive an error: cannot find module 'cucumber'. I have cucumber and protractor and protractor-cucumber installed global and can execute them individually but not when trying to execute Protractor with a framework of cucumber.

The config file I am using is as follows:

var env = require('./environment.js');

// A small suite to make sure the cucumber framework works.
exports.config = {
    seleniumAddress: env.seleniumAddress,

    framework: 'cucumber',

    // Spec patterns are relative to this directory.
    specs: [
      '../app/modules/auth/html/cucumber/*.feature'
    ],

    capabilities: env.capabilities,

    baseUrl: env.baseUrl,

    cucumberOpts: {
      require: '../app/modules/auth/html/cucumber/stepDefinitions.js',
      tags: '@dev',
      format: 'summary'
    }
};

Any suggestions what I can try in order to resolve the issue?

stacktrace: Using the selenium server at http://localhost:4444/wd/hub [launcher] Running 1 instances of WebDriver [launcher] Error: Error: Cannot find module 'cucumber' at Function.Module._resolveFilename (module.js:338:15) at Function.Module._load (module.js:280:25) at Module.require (module.js:364:17) at require (module.js:380:17) at Object.exports.run (/Users/lbrown/node_modules/protractor/lib/frameworks/cucumber.js:13:18) at /Users/lbrown/node_modules/protractor/lib/runner.js:293:35 at _fulfilled (/Users/lbrown/node_modules/protractor/node_modules/q/q.js:797:54) at self.promiseDispatch.done (/Users/lbrown/node_modules/protractor/node_modules/q/q.js:826:30) at Promise.promise.promiseDispatch (/Users/lbrown/node_modules/protractor/node_modules/q/q.js:759:13) at /Users/lbrown/node_modules/protractor/node_modules/q/q.js:573:44 [launcher] Process exited with error code 100

4

4 Answers

3
votes

It's still likely that cucumber isn't installed globally.

Try this on your command line:

node
> require('cucumber')

If that complains about cucumber not being found, then you didn't install cucumber globally. Otherwise, can you paste the stacktrace.

2
votes

I entered the command

npm install cucumber

and the issue is resolved.

0
votes

I've had a similar issue on Windows 7, that was resolved by adding an environment variable so that Node could locate modules installed with the -g flag, as per Nodejs cannot find installed module on Windows?

-1
votes

Add these dependencies:

  "dependencies": {
    "@cucumber/cucumber": "7.0.0",
    "@types/jasmine": "^3.5.10",
    "@types/jasminewd2": "^2.0.8",
    "@types/node": "^13.7.7",
    "@types/react": "16.8.24",
    "jasmine": "^3.5.0",
    "protractor": "^7.0.0",
    "protractor-cucumber-framework": "^7.0.2",
    "ts-node": "8.6.2",
    "typescript": "^3.2.2"
  }