gpt4 book ai didi

node.js - 使 npm start 脚本在特定端口运行 ng 服务

转载 作者:行者123 更新时间:2023-12-02 18:39:20 24 4
gpt4 key购买 nike

我的package.json中有一些脚本,我需要知道如何让start脚本正确接受-port angular-cli 的参数。

  "scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},

我们需要这个,因为我们希望同时运行软件的多个实例。目前,如果我有一个项目在默认端口 4200 上运行,并尝试在第二个终端窗口中运行 npm start -port 4300,我会得到“端口 4200 已在使用中。使用 '- -port' 指定不同的端口。”

我该怎么做才能让我的构建在特定端口上运行?如何才能将端口号从命令行传递到 npm start 脚本中?

最佳答案

如果添加“--”,参数将通过:

npm start -- --port 4301

关于node.js - 使 npm start 脚本在特定端口运行 ng 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47165616/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com