Node.js 如何使用配置在单个package.json行中运行多个命令

Node.js 如何使用配置在单个package.json行中运行多个命令,node.js,angular,npm,package.json,universal,Node.js,Angular,Npm,Package.json,Universal,我想在一个npm运行命令中运行tobuild命令(clienr和server)。 因此,在我的package.json脚本部分,我添加了这一行: "build-all": "ng build --prod && ng run web-app:server", 当我运行以下命令时会出现问题:npm run build all--configuration=qa.europe 单独运行每个命令时加载配置,但运行上述命令时不加载配置 有什么想法吗?您可以尝试使用postinstall

我想在一个npm运行命令中运行tobuild命令(clienr和server)。 因此,在我的package.json脚本部分,我添加了这一行:

"build-all": "ng build --prod && ng run web-app:server",
当我运行以下命令时会出现问题:npm run build all--configuration=qa.europe

单独运行每个命令时加载配置,但运行上述命令时不加载配置


有什么想法吗?

您可以尝试使用postinstall,它将如下所示:

"scripts": {
    "start": "ng run web-app:server",
    "postinstall": "ng build --prod --configuration=qa.europe",
}
因此,在npm安装之后,UI的构建开始了。然后启动服务器。

您可以试试这个

  "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它将运行“start:production”和“start:prod”两个脚本

运行
npm run build all
时是否出现任何错误?请添加package.json内容,以便我们可以看到脚本我没有收到任何错误,但配置不适用,但我正在更改每个环境的配置。我无法在package.json中硬编码它