简体   繁体   English

在 package.json 脚本键:npm 运行与否?

[英]In package.json scripts key: npm run or not?

In an online tutorial, the package.json said (simplified):在在线教程中,package.json 说(简化):

"scripts": {
  "dev": "npm run webpack -- --mode development"
},

I usually write, and it works:我通常写,它的工作原理:

"scripts": {
  "dev": "webpack --mode development"
},

Is the first version in any way preferable?第一个版本是否更可取? I understand the meaning of -- , but I do not know whether encapsulating the command in another npm run call provides any benefits.我理解--的含义,但我不知道将命令封装在另一个npm run调用中是否有任何好处。

The first call allows you to change the webpack command used, or add additional arguments, or even run an entirely different command at all.第一个调用允许您更改使用的webpack命令,或添加额外的 arguments,甚至运行完全不同的命令。

For example, npm run tsc on my repos runs npm run delDist && tsc .例如, npm run tsc运行npm run delDist && tsc

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM