Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bash: jest: command not found

  • I know I installed jest cause I can see its location and I tried the test they ask after you download it and it was working fine
  • Every time I try the jest command it says "bash: jest: command not found." I've seen others recommend ./node_modules/.bin/jest but that still didn't help even if I did use Sudo i still get "No such file or directory" even though i can see that there is a directory in that path.
  • I tried npm test and I get an error regarding a package.json
  • I saw someone recommend to remove jest and install again with npm install -g jest command but that lead to a series of error about EACCES: permission denied.
  • I thought it may have to do w my node version but it's 10.16.0 so I don't think its that.

Honestly, I feel like I'm all over the place tryna figure out why this is happening so any suggestion/help would be appreciated

other "solutions" I've tried are: node_modules/jest/bin/jest reversestring/test.js --watch ./node_modules/.bin/jest steps/test.js --watch

note: revesersestring and steps were exercises I was trying to run jest on

My OS is MAC

like image 906
Kaiaya Avatar asked May 20 '26 02:05

Kaiaya


1 Answers

The jest library must be installed globally. Otherwise you need to run it from the absolute path in your node_modules folder. The easiest way to run the jest command is to run an npm script. Like below:

npm test

you can install the jest-cli globally by running:

npm install -g jest-cli

like image 116
Mark Avatar answered May 22 '26 16:05

Mark