简体   繁体   中英

“module”: “esnext” in tsconfig.json did not remove Dynamic Lazy load module error

After updating my app to angular 8 my routes did not change to new syntax loadChildren: () => import('./listing/listing.module').then(m => m.ListingModule) so i did this manually but i am getting Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. error.

After reading some answers i found to change "module": "esnext" in tsconfig.json file. But even after this change my error is still there.

Below is my code:

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

tsconfig.app.json

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "types": []
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

Can please anyone tell what is wrong in the code?

This might help, my tsconfig.app.json looks like this:

{
 "extends": "../tsconfig.json",
 "compilerOptions": {
  "outDir": "../out-tsc/app",
  "baseUrl": "./",
  "types": []
 },
 "exclude": [
  "test.ts",
  "**/*.spec.ts"
 ]
}

First try to restart your angular cli server also

If that is not the case add this in your tsconfig.app.json also

"module": "esnext"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM