NRWL / NX Nestjs将不会覆盖全局tsconfig.json

时间:2019-06-15 17:14:21

标签: nestjs nrwl nrwl-nx

我创建了一个nx工作区,并在其中建立了一个基于https://github.com/nartc/nest-mean项目的nestjs项目。
初次尝试为项目提供服务时,它会编译但无法运行,并显示一条错误消息

/mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:844
    throw new Error("Cannot parse config file: '" + fullFilename + "': " + e3);
          ^
Error: Cannot parse config file: '/mnt/LinuxData/linuxDev/nest-mean-nrwl/config/development.ts': SyntaxError: Unexpected token export
    at Config.util.parseFile (/mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:844:11)
    at /mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:600:28
    at Array.forEach (<anonymous>)
    at /mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:596:14
    at Array.forEach (<anonymous>)
    at Config.util.loadFileConfigs (/mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:595:13)
    at new Config (/mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:136:27)
    at Object.<anonymous> (/mnt/LinuxData/linuxDev/nest-mean-nrwl/node_modules/config/lib/config.js:1649:31)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.config (/mnt/LinuxData/linuxDev/nest-mean-nrwl/dist/apps/mean-be/webpack:/external "config":1:1)

我在一个单独的nestjs项目中处理了代码,发现tsconfig.json将模块要求为commonjs而不是esnext。

我认为这只是在tsconfig.json中覆盖此设置的简单问题 文件apps / mean-be / tsconfig.json变为:

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
  "module": "commonjs",  *<-- override to module added here*.
    "types": [
      "node",
      "jest"
    ]
  },
  "include": [
    "**/*.ts"
  ]
}

,但似乎没有任何作用,它可以编译,但无法运行,并且出现与以前相同的错误消息。

我必须更改全局tsconfig.json文件中的设置,以便tsconfig.json变为:

{
  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "commonjs",           <-- changed from esnext to commonjs 
    "typeRoots": ["node_modules/@types"],
    "lib": ["es2017", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": ".",
    "paths": {}
  },
  "exclude": ["node_modules", "tmp"]
}

(您可以在https://github.com/DouglasWebster/nest-mean-nrwl上找到该项目的完整副本)

在尝试覆盖项目tsconfig.json文件中的模块时我做错了什么吗?还是应该报告的错误?

如果这是应该的工作方式,那么当我尝试向项目中添加角度前端服务器时,将全局tsconfig.json保留为"module": "commonjs"会导致问题吗?

任何帮助将不胜感激,谢谢。

0 个答案:

没有答案