import('./listing/listing.module').then(m =>-6ren">
gpt4 book ai didi

javascript - "module": "esnext" in tsconfig. json没有去掉Dynamic Lazy load模块报错

转载 作者:行者123 更新时间:2023-11-30 06:12:17 27 4
gpt4 key购买 nike

将我的应用程序更新到 Angular 8 后,我的路由没有更改为新语法 loadChildren: () => import('./listing/listing.module').then(m => m.ListingModule) 所以我手动执行此操作,但我收到 Dynamic import is only supported when '--module' flag is 'commonjs' or 'esNext'. 错误。

阅读一些答案后,我发现要更改 tsconfig.json 文件中的 "module": "esnext"。但即使在进行此更改之后,我的错误仍然存​​在。

下面是我的代码:

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"
]
}

谁能告诉我代码中有什么问题吗?

最佳答案

这可能会有所帮助,我的 tsconfig.app.json 如下所示:

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

关于javascript - "module": "esnext" in tsconfig. json没有去掉Dynamic Lazy load模块报错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58167298/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com