简体   繁体   English

如何通过配置在单个 package.json 行中运行多个命令

[英]How to run multiple commands in a single package.json line with configuration

I want to run the to build commands (clienr and server) in one npm run commands.我想在一个 npm 运行命令中运行构建命令(客户端和服务器)。 So on my package.json scripts section I added this line:所以在我的 package.json 脚本部分我添加了这一行:

"build-all": "ng build --prod && ng run web-app:server",

The problem occurs when I run this commands: npm run build-all --configuration=qa.europe.当我运行以下命令时出现问题:npm run build-all --configuration=qa.europe。

The configuration is loaded when I run each commands separately but not when I run the above commands.单独运行每个命令时会加载配置,但运行上述命令时不会加载配置。

Any ideas?有任何想法吗?

You can try to use postinstall, it will look as next:您可以尝试使用 postinstall,它将如下所示:

"scripts": {
    "start": "ng run web-app:server",
    "postinstall": "ng build --prod --configuration=qa.europe",
}

So after npm install, the build of your UI starts.所以在 npm 安装之后,你的 UI 的构建就开始了。 And after that will start your server.之后将启动您的服务器。

You can try this.你可以试试这个。

  "scripts": {
    "start:production": "npm install && npm run build && npm run start:prod",
    "start:prod": "cross-env NODE_ENV=production node server",
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  }

npm run start:production it will run "start:production" & "start:prod" both scripts npm run start:production 它将运行“start:production”和“start:prod”这两个脚本

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

相关问题 如何使用 package.json 脚本运行多个 PowerShell 命令 - How to run multiple PowerShell commands with package.json scripts 如何在 package.json 的脚本中运行多个 powershell 命令 - How to run multiple powershell commands in scripts for package.json package.json 中的多个命令 - Multiple commands in package.json 如何从package.json在Windows命令行(bash,babun)中运行2个npm命令? - How to run 2 npm commands in Windows command line (bash, babun) from package.json? 如何使用MacOS在package.json上调用多个命令 - How to call multiple commands on package.json using MacOS 如何在 npm package.json 脚本中链接多个命令 - How to chain multiple commands in npm package.json scripts 如何在 package.json (nodeJs) 中创建跨平台脚本(单行多个命令) - how to create cross platform scripts (multiple command for single line) in package.json (nodeJs) 如何使用PM2运行多个package.json脚本之一? - How to run one of multiple package.json scripts with PM2? 如何使用节点映像中的单行“docker run”命令在当前目录中的本地计算机上生成 package.json 文件 - How to generate a package.json file on local machine in current directory, using single line "docker run" command from node image 如何将.sequelizerc配置放入package.json中? - How to put .sequelizerc configuration in package.json?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM