Search code examples
javascriptnode.jsnpmpathava

How can NPM run a command that isn't in path


The ava command is not in my path. I can not run it from in the project directory that contains some AVA tests.

My npm test command of my project is set to ava tests/*.js --verbose, and can somehow call the ava command from the same location in the terminal.

My questions is: how is npm calling the ava command? I suspect it is calling it from the project's node_modules folder, but I could not find it in any source.

If anyone can explain how this happens, or better yet show me the source, I would really appreciate it.


Solution

  • When you run the npm run [script] or in this case npm test, NPM is smart enough to try to execute the binary from the node_modules/.bin directory first.