Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a separate file for "scripts"

In my package.json file, I have so many commands in "scripts" like the code below.

"scripts" {
  "script1": "command example",
  "script2": "command example",
  "script3": "command example",
  "script4": "command example",
  "script5": "command example",
  "script6": "command example",
  "script7": "command example",
  ...
}

Is there any way to move those commands to another file?

For instance, I'm thinking about moving them to a file like bin/commands.js.

like image 220
K-Sato Avatar asked Jul 21 '26 14:07

K-Sato


1 Answers

This is a common problem, having your package.json get bloated from too many scripts. There is a pretty good solution built by Kent Dodds, called NPS (npm-package-scripts). Unfortunately there are not many solutions for this problem.

PRO: you define the script in a js file so you have more flexibility, reduces clutter in your package.json, good community support.

CON: Not many just a different command (nps vs npm)

like image 169
Joey Avatar answered Jul 23 '26 04:07

Joey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!