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?
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With