我有一个集成的NX工作区,其中有一个Angular应用程序和一个Nativescript应用程序.我试图通过@nx/nest添加一个Nest.js应用程序.每当我添加新应用程序时,它会安装@nx/webpack插件并将该插件添加到nx.json.我注意到Nativescript正在使用自己的@nativescript/webpack模块.

每当我试图构建或服务任何应用程序时,它会立即抛出一个类型错误,因为它试图使用@nx/webpack与Nativescript.这里是错误

 NX   Unable to create nodes for apps/nativescript-mobile-app/webpack.config.js using plugin @nx/webpack/plugin. 


         Inner Error: TypeError [ERR_INVALID_ARG_TYPE]: The "paths[1]" argument must be of type string. Received undefined

有没有人遇到这个问题与冲突的Webpack模块?是否可以指定哪些应用程序使用NX插件?

推荐答案

@rthames62在官方的Discord服务器上提到了他的问题,并向我提供了他的nx.json也是他的NestJS project.json.&

如果在座的任何人都面临这个问题,

添加@nx/nest似乎是将全局@nx/webpack/plugin添加到您的nx.json中,而不是将其添加到NestJS project.json中作为目标:

  "plugins": [
    {
      "plugin": "@nx/webpack/plugin",
      "options": {
        "buildTargetName": "build",
        "serveTargetName": "serve",
        "previewTargetName": "preview"
      }
    },
    {
      "plugin": "@nx/eslint/plugin",
      "options": {
        "targetName": "lint"
      }
    }
  ]

删除@nex/webpack/plugin项.

现在把它添加到你的NestJS project.json:

    "build": {
      "executor": "@nx/webpack:webpack",
      "outputs": ["{options.outputPath}"],
      "defaultConfiguration": "production",
      "options": {
        "target": "node",
        "compiler": "tsc",
        "outputPath": "dist/apps/YOUR NEST APP",
        "main": "apps/YOUR NEST APP/src/main.ts",
        "tsConfig": "apps/YOUR NEST APP/tsconfig.app.json",
        "assets": ["apps/YOUR NEST APP/src/assets"],
        "webpackConfig": "apps/YOUR NEST APP/webpack.config.js"
      },
      "target": "node",
      "compiler": "tsc",
      "configurations": {
        "development": {
        },
        "production": {
        }
      }
    }

如果您在提供NestJS应用程序时遇到问题,请将NestJS project.jsonserve目标更改为:


    "serve": {
      "executor": "@nx/js:node",
      "defaultConfiguration": "development",
      "options": {
        "buildTarget": "YOUR NEST APP:build"
      },
      "target": "node",
      "compiler": "tsc",
      "configurations": {
        "development": {
          "buildTarget": "YOUR NEST APP:build:development"
        },
        "production": {
          "buildTarget": "YOUR NEST APP:build:production"
        }
      }
    }

请记住,用NestJS应用程序的名称更改YOUR NEST APP.

很高兴我能帮上忙.

Angular相关问答推荐

将kendo—colorpicker的kendo弹出窗口附加到组件''

Ionic 5角形共享两个模块之间的组件

带逻辑的组件decorator 中的Angular 主机侦听器属性

停靠的Angular 应用程序的Nginx反向代理无法加载assets资源

带迭代的Angular 内容投影

VS代码中带Angular 17的缩进新控制流

为什么初始化值为 1 的BehaviorSubject 不能分配给类型number?

如果observableA在1秒前触发,则过滤掉observableB

如果Angular 数据为空,如何设置N/A

可观察的等待直到另一个可观察的值

如何在Angular2中基于特定的构建环境注入不同的服务?

如何在 Angular4 中访问组件的 nativeElement?

请添加@Pipe/@Directive/@Component 注解

Angular2 Pipes:输出原始 HTML

无法绑定到matDatepicker,因为它不是 input的已知属性

在 Angular rxjs 中,我什么时候应该使用 `pipe` 与 `map`

错误:angular2 中没有 HttpHandler 的提供者

No provider for Router?

路由 getCurrentNavigation 始终返回 null

使用 EventEmitter 传递参数