@Quentin npm
lacks a built-in feature to accomplish that.
Surprisingly, he was mistaken ☺️
In the past, older versions of NPM v7 and v8 had a specialized command for adding scripts to the package.json
- more information available here
and the syntax used would be
npm set-script <name> "<command>"
However, the latest version of NPM has introduced changes where all modifications concerning the package.json
file can now be made using the pkg
argument
npm pkg set scripts.<name>="<command>"
Within this method, the scripts
represent the string path to a specific section in a json
By utilizing npm pkg set
, any part of your package.json file can be adjusted. Remember that options like set
, get
, and delete
are also available
Further details can be found here