calva icon indicating copy to clipboard operation
calva copied to clipboard

Remove npx from all scripts in package.json

Open bpringe opened this issue 3 years ago • 1 comments

I think npx's purpose is more for one-off commands (so you don't need to install the package globally).

I experienced an issue with npx being used in a script: when I ran the build task, I noticed one of the prettier scripts that uses on-change seemed to be hung awaiting my input to say whether to install it or not (since it was not installed - it wasn't part of the dev deps). We could use the --yes option to cause it to be installed without a prompt, but this is just an added requirement to remember when using npx in scripts.

One other downside to using npx is if we don't have a version of the package installed in the dev deps, then we aren't controlling which version of the package the developer is using when they run the script. For example, we didn't have onchange as a dev dep (something I added in a recent PR), so different developers could be using different versions of onchange (I think - unless it always uses the latest even if you already had a version installed, but I doubt that's the case).

So, by using packages directly in npm scripts, we enforce the adding of those packages to our dev deps, which enforces a consistent developer experience. When the developer runs npm install (which they have to do anyway to run Calva), they'll have the versions of the packages defined in the dev deps. Then everyone uses the same version of those packages during development, and we don't have to remember to add the --yes flag to scripts to avoid the prompt issue.

@PEZ Thoughts?

bpringe avatar Jul 31 '22 18:07 bpringe

I have missed this suggestion. It makes sense.

PEZ avatar Oct 01 '22 14:10 PEZ