3 ms·
npx doesn't run project-installed packages, it uses global downloads The "npm run" is a command for running defined scripts in your package.json The equivalen
by gavinray 3y ago
npx doesn't run project-installed packages, it uses global downloads
The "npm run" is a command for running defined scripts in your package.json
The equivalent of "npm run" in yarn is just "yarn", for example: "yarn start"/"yarn dev".
What "yarn run" does is allow you to run binaries installed from "dependencies"/"devDependencies".
Say that I run the following:
yarn install --dev nodemon ts-node typescript
I can then run
yarn run tsc --init / yarn run nodemon / yarn run ts-node
And it will invoke the local "./node_modules" package binaries.
This is useful when you want to ensure version-locked, per-project binaries.
- hoten 3y ago`npx <package>` does run project installed binaries, if they exist (node_modules/.bin/<package>). In that scenario it's equivalent to `yarn <package>`. Otherwise yes it falls back to a global package, and a prompt to install if missing.
- addicted 3y agonpx has supported local packages for quite some time at this point.