Testcafe command not found when installed through "npm install"
Asked Answered
G

3

8

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?

Gesticulate answered 1/2, 2019 at 12:5 Comment(1)
Can you show us your packege.json?Catalyze
F
10

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

Faltboat answered 1/2, 2019 at 13:36 Comment(0)
A
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.

Airstrip answered 4/2, 2019 at 22:37 Comment(0)
J
4

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

Jive answered 4/2, 2019 at 7:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.