1

So I have a package.json file which I used on a different computer to run javascript tests. Now I have moved to another computer, I have the node_modules folder, package.json, package-lock.json and yarn.lock. If I run npm install in the same folder where package.json is located, shouldn't jest also be installed? Since Jest is located in package.json. If I run jest from the terminal I get command not found

skyboyer
  • 22,209
  • 7
  • 57
  • 64
Roland
  • 885
  • 3
  • 12
  • 16

2 Answers2

1

To use an npm package from anywhere you need to have it installed globally like this:

npm install -g jest

An other solloution would be to add a new script in the package.json like this:

scripts:{
   "jest":"jest"

}

And the type npm run jest

You can also have a look at this question : How to use package installed locally in node_modules?

Manos Kounelakis
  • 2,848
  • 5
  • 31
  • 55
1

Probably because the node_modules/.bin of your project is not in your $PATH try adding it or run ./node_modules/.bin/jest

CharybdeBE
  • 1,791
  • 1
  • 20
  • 35