'How can I run an npm script installed in the root of a learn repo, from a child package?

For instance, I want to run jest tests for one of my packages.

I set up the test script in the child package.json:

"test" : "jest"

However when I got to the package directory and run:

npm test

I get:

sh: jest: command not found

This makes sense because I've only installed jest in the root package since it is a dev dependency.

What do I need to do to make the npm package jest available in the child packages?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source