Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testcafe command not found when installed through "npm install"

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?

like image 258
Leonardo Veiga Avatar asked Feb 01 '19 12:02

Leonardo Veiga


Video Answer


2 Answers

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

like image 165
Alex Kamaev Avatar answered Sep 19 '22 16:09

Alex Kamaev


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.

like image 31
hdorgeval Avatar answered Sep 23 '22 16:09

hdorgeval