7

When I installed testcafe with command sudo npm install -g testcafe I was able to use the command "testcafe" in the terminal, running tests like testcafe browser test, but now I formatted my OS and installed it with just npm install with the packege.json of my project and when I try to use "testcafe" command to run tests I get the message testcafe: command not found.

Now I'm able to run tests just if I call the node module, like /usr/bin/node node_modules/testcafe/bin/testcafe.js browser test

It seems that the "testcafe" command alias to call the node module was not created when I installed it with just npm install.

Any thoughts on how can I fix it or why this happened?

Alex Skorkin
  • 4,034
  • 3
  • 21
  • 44

3 Answers3

8

It is expected behavior. If you want to use the testcafe command from the command line, you need to install the testcafe package globally using the -g argument. Please refer to the following article to get more details: https://devexpress.github.io/testcafe/documentation/using-testcafe/installing-testcafe.html

Alex Kamaev
  • 4,985
  • 1
  • 10
  • 26
6

As a feedback on how to install TestCafe, I recommend to install it locally instead of globally, especially if your tests are executed in a CI environment, because a CI environment may be reformatted at any time (like your dev machine) or may be used by different tenants that might each needs a special version of TestCafe.

hdorgeval
  • 2,854
  • 4
  • 14
4

You can use npx to run any local binary without installing it globally.

Roman Eremin
  • 1,159
  • 6
  • 8