am试图同时运行两个单独的项目。
两个单独的项目是sailsjs应用程序。
使用Visual Studio代码。
我想以vscode“调试模式”启动这些项目。
每个项目都需要在不同的端口上运行。
在每个项目的local.js中,我都提到过:
module.exports = {
port: xx
}
但我的项目中只有一个似乎可以正常运行。
我四处张望。我认为我必须在launch.json
上添加某种形式的参数,
"runtimeArgs": ["--inspect=9230"]
但仍然出现错误:
"2019-03-05T11:31:25.085Z - error: Grunt :: Starting inspector on 127.0.0.1:9985 failed: address already in use"
当我重新启动其中一个应用程序时。其他应用程序似乎运行良好。
从这个错误中,我了解到有某种grunt模块可以为调试主机生成一个随机端口。
答案 0 :(得分:0)
在local.js
中定义的端口是项目端口,sails inspect
使用default端口进行调试127.0.0.1:9229
。
因此,当您在两个项目中尝试使用sails inspect
时,第一个项目将使用默认端口,然后第二个将失败。
风帆documentation说“要在风帆中使用标准(命令行)节点调试器,您始终可以只运行node inspect app.js
”,然后您可以使用命令node inspect --port=xxxx app.js
。>
示例:
项目A:
module.exports = {
port: 2000
}
node inspect --port=9980 app.js
项目B:
module.exports = {
port: 2001
}
node inspect --port=9981 app.js
我希望这就是你所需要的。