0

I managed to run cucumber from CLI with

node ./node_modules/cucumber/bin/cucumber

but I wasn't able to run it simply with

cucumber

Windows tried to run it as executable, so it opened some window about missing file association. Is there a way to solve this? Note that I don't want to add nodejs as .js file association, since I am pretty sure the same code won't work on github when travis tries to run the script.

I installed the package with npm.

"devDependencies": {
    ...
    "cucumber": "^0.8.1",
inf3rno
  • 24,976
  • 11
  • 115
  • 197

2 Answers2

0

You have to install cucumber globally, i.e. npm install cucumber -g This way, npm creates a binary / symlink in some standard 'on-path' directory (i.e., where the executables should be put), so you can run it from command line.

In my notebook (Linux), I run

sudo npm install cucumber -g

which creates a symlink

/usr/bin/cucumberjs -> /usr/lib/node_modules/cucumber/bin/cucumber.js

which means I can run it by cucumberjs command. If some dependency has cucumber command hardwired into it (without the js suffix), I'd create another symlink manually.

/usr/bin/cucumber -> /usr/bin/cucumberjs

If you run into the following problems, maybe try using nvm, not to polute your system folders.

Tomas Kulich
  • 14,388
  • 4
  • 30
  • 35
0

Add this to your ~/.bashrc or ~/.bash_profile.

It will add ./node_modules/.bin to your PATH

export PATH=$HOME/bin:./node_modules/.bin:$PATH
Yada
  • 30,349
  • 24
  • 103
  • 144