I have a build script in javascript project that uses parcel to iterate through folders and finding index files and then building those projects. When I find an index file I run this command:
npx parcel build ${indexFilePath} --out-dir ${outDir} --target node
But, if the person running this build script has not installed packages with npm i
yet, the npx command will install the latest version of parcel-bundler, where --out-dir is now deprecated and breaking the entire script.
Here is what's going on, distilled:
$ rm -rf node_modules
$ npm i
$ npx parcel --version
1.12.4
$ rm -rf node_modules
$ npx parcel --version
2.0.0-beta.2
Is there any option for npx to use the version in the package.json file that is already in the project and install it to node_modules? Or do I just ingrate the install step into my build? It just seems overkill, since all I need to build is parcel.
Am I abusing npx by using it like this?
jq
, but I prefer this solution. – Sard