I have a JavaScript app I'm bundling with webpack. Per the docs, I'm using this command to start bundling:
npx webpack
Each time I get this output:
npx: installed 1 in 2.775s
I've verified that the webpack command exists in my ./node_modules/.bin
directory where npx is looking. Can anyone think of why it's downloading webpack every time? It can take up to 7 seconds to complete this step, which is slowing down my builds.
Old answer:
npx
doesn't reuse previously installed packages, instead it pulls down that package's dependencies every time that you run it.
Update on 06 May 2022 for newer versions of npx
e.g. ver. 8.3.0:
Now npx
does use previously installed packages without need to reinstall anything! Looks like npm
team fixed old issue some time ago, not sure which version was first that received this fix.
npx allows you to run an arbitrary command from an npm package (either one installed locally, or fetched remotely), in a similar context as running it via npm run.