4

If you use npm install <module> --save it writes this module into the package.json, which is very useful.

The package.json has an area for scripts. I want to add some scripts here automatically, so what would be useful would be a command to use add scripts here instead of opening the files yourself.

Something like npm add-script <name> <command>

Is there really nothing like this?

smottt
  • 3,272
  • 11
  • 37
  • 44

1 Answers1

4

Yo can use npm add script library.

  • Install the library in your project:

    npm install -g npm-add-script
    
  • Use it, like this npmAddScript -k <name> -v <command>, for example:

    npmAddScript -k test -v "node test.js"
    

More info in the official page of npm add script.

Javier C.
  • 7,859
  • 5
  • 41
  • 53