最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - bash: jest: command not found - Stack Overflow

programmeradmin6浏览0评论
  • 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 mand it says "bash: jest: mand not found." I've seen others remend ./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 remend to remove jest and install again with npm install -g jest mand 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

  • 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 mand it says "bash: jest: mand not found." I've seen others remend ./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 remend to remove jest and install again with npm install -g jest mand 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

Share Improve this question edited Jul 26, 2019 at 16:16 Kaiaya asked Jul 23, 2019 at 18:47 KaiayaKaiaya 1011 gold badge1 silver badge4 bronze badges 8
  • 1 Did you install it globally with the -g option to npm? – Mark Commented Jul 23, 2019 at 18:50
  • 1 Is the x flag present on the binary? If not, it isn’t executable. – Thorbjørn Ravn Andersen Commented Jul 23, 2019 at 18:51
  • 1 @Mark I did install it globally – Kaiaya Commented Jul 23, 2019 at 18:56
  • 1 @ThorbjørnRavnAndersen how would I check that? – Kaiaya Commented Jul 23, 2019 at 19:00
  • 1 Maybe try sudo npm install -g jest – Mark Commented Jul 23, 2019 at 20:05
 |  Show 3 more ments

3 Answers 3

Reset to default 9

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 mand is to run an npm script. Like below:

npm test

you can install the jest-cli globally by running:

npm install -g jest-cli

Running:

npm install --save-dev jest-cli

Will put the jest mand into the directory:

node_modules/.bin/

This directory is what is used to run mands via package.json

For example:

"scripts": {
  "test": "jest -i"
},

Will be runnable via:

npm run test

Or:

yarn test

I resolved my problem by using Jest Runner extension in VSC.

发布评论

评论列表(0)

  1. 暂无评论