Like when you're already working in the cli, it would be helpful to add scripts directly from the cli, without navigating the file and add it manually. Regardless of editing the file with bash. I already searched npm docs and didn't find anything like this.
package.json
is, unsurprisingly, JSON so you could write a program which reads it, adds something to the appropriate section, then writes back to it.
npm
doesn't have anything built-in to do that though.
You could also use a terminal editor like vim, nano, or emacs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.