[英]Adding npm package.json scripts per console command
If you use npm install <module> --save
it writes this module into the package.json
, which is very useful. 如果使用
npm install <module> --save
它将把这个模块写入package.json
,这非常有用。
The package.json
has an area for scripts. package.json
有一个脚本区域。 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>
类似于
npm add-script <name> <command>
Is there really nothing like this? 真的没有这样的东西吗?
Yo can use npm add script library. 可以使用npm添加脚本库。
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 <name> -v <command>
这样使用它,例如:
npmAddScript -k test -v "node test.js"
More info in the official page of npm add script . 有关更多信息,请参见npm add script的官方页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.