Skip to content
Discussion options

You must be logged in to vote

node runs a file. npm run runs a named script from package.json. npx runs a package binary.

So:

npm run dev works because dev is usually a script alias, like "dev": "next dev"
npx jest works because jest is a CLI from node_modules/.bin

node jest usually does not work because jest is not a file path you are passing to Node. The closer equivalent would be something ugly like:

node ./node_modules/jest/bin/jest.js

In practice, for tests, npm test / npm run test is usually better than npx jest if Jest is already in your project.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by miled60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants