【问题标题】:Angular Nx Nrwl - Cannot parse tsconfig.base.json: PropertyNameExpected in JSON when try to create a new libAngular Nx Nrwl - 尝试创建新库时无法解析 tsconfig.base.json:JSON 中的 PropertyNameExpected
【发布时间】:2021-11-15 04:52:35
【问题描述】:

我收到这个错误

Cannot parse tsconfig.base.json: PropertyNameExpected in JSON at position 891

当我在 CLI 上运行 nx g @nrwl\angular:lib libName

我的 tsconfig.base.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "rootDir": ".",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "module": "esnext",
    "lib": ["es2017", "dom"],
    "skipLibCheck": true,
    "skipDefaultLibCheck": true,
    "baseUrl": ".",
    "paths": {
      "@admin-env/*": ["apps/admin/src/environments/*"],
      "@admin/*": ["apps/admin/src/app/*"],
      "@portal-env/*": ["apps/portal/src/environments/*"],
      "@portal/*": ["apps/portal/src/app/*"],
    }
  },
  "exclude": ["node_modules", "tmp"]
}

当我运行时,我收到错误Cannot parse tsconfig.base.json: PropertyNameExpected in JSON at position 891

当我尝试运行 npx nx g @nrwl/angular:lib libNamenx g @nrwl/angular:lib 时也会发生同样的情况

我用VScode写代码,tsconfig.base.json没有错误警告(lint)

【问题讨论】:

    标签: json angular angularjs nrwl-nx nrwl


    【解决方案1】:

    paths 列表末尾有逗号“,”时出现此错误。

    "@portal/*": ["apps/portal/src/app/*"],  <<< REMOVE this comma
    

    【讨论】:

    • 是的 - 花了几个小时寻找解决方案,就是这么简单的解决方法。谢谢
    【解决方案2】:

    是的,这正是解决方案 - 删除逗号: "路径": { "@sokar/products":["libs/products/src/index.ts"],enter image description here

    【讨论】:

    • 您的意思是将该评论编辑到您的答案中吗?
    猜你喜欢
    • 2019-05-21
    • 2021-03-08
    • 2019-05-23
    • 2020-08-21
    • 1970-01-01
    • 1970-01-01
    • 2018-07-23
    • 2020-08-29
    • 2019-11-10
    相关资源
    最近更新 更多