使用nx run-many执行serve任务时陷入无限循环且无日志输出的问题求助
nx run-many执行serve任务时陷入无限循环且无日志输出的问题求助
我是个NX新手,最近碰到个棘手的问题:我想同时运行两个项目——一个是Next.js前端(路径apps/frontend),另一个是Nest.js后端(路径apps/monolith)。
单独执行nx run frontend:serve或者nx run monolith:serve的时候,一切都正常,服务能启动,日志也能正常显示。但当我尝试用nx run-many -t=serve同时启动两个服务时,就陷入了一个奇怪的执行循环里。
执行命令后,终端显示的状态大概是这样的:
NX Running serve for 2 projects, and 1 requisite tasks... Duration │ │⠏ frontend:serve:development Continuous │⠏ monolith:serve:development Continuous │· Waiting for task... └ > ✔ monolith:build 26ms
我特意去检查了一下,两个服务其实都正常运行起来了,但终端里完全看不到任何来自前端或后端的日志输出,而且这两个*:serve:development旁边的加载器一直在无限旋转,根本停不下来。
我想请教一下,怎么才能让这两个服务的日志在终端里正常显示出来?另外这个无限循环的状态要怎么解决呢?
附上两个项目的project.json配置:
前端(frontend)的project.json
{ "name": "frontend", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/frontend", "projectType": "application", "tags": [], "// targets": "to see all targets run: nx show project frontend --web", "targets": { "build": { "executor": "@nx/next:build", "outputs": ["{options.outputPath}"], "defaultConfiguration": "production", "dependsOn": [{ "dependencies": false, "target": "build" }], "options": { "outputPath": "/apps/frontend" } }, "serve": { "executor": "@nx/next:server", "defaultConfiguration": "development", "options": { "buildTarget": "frontend:build", "dev": true }, "configurations": { "development": { "buildTarget": "frontend:build:development", "hmr": true }, "production": { "buildTarget": "frontend:build:production", "dev": false } } } } }
后端(monolith)的project.json
{ "name": "monolith", "$schema": "../../node_modules/nx/schemas/project-schema.json", "sourceRoot": "apps/monolith/src", "projectType": "application", "tags": [], "targets": { "build": { "executor": "nx:run-commands", "options": { "command": "webpack-cli build", "args": ["node-env=production"] }, "dependsOn": [{ "dependencies": false, "target": "build" }], "configurations": { "development": { "args": ["node-env=development"] } } }, "serve": { "continuous": true, "executor": "@nx/js:node", "defaultConfiguration": "development", "dependsOn": ["build"], "options": { "buildTarget": "monolith:build", "runBuildTargetDependencies": false }, "configurations": { "development": { "buildTarget": "monolith:build:development" }, "production": { "buildTarget": "monolith:build:production" } } }, "test": { "options": { "passWithNoTests": true } } } }
内容来源于stack exchange
相关产品推荐
相关产品推荐

