gpt4 book ai didi

angular - 无法解析应用程序模块的参数

转载 作者:太空狗 更新时间:2023-10-29 17:15:45 24 4
gpt4 key购买 nike

我正在尝试使用 angular 1.6 和 5 运行混合应用程序。手动引导工作正常。当我尝试引导混合应用程序时,我收到以下错误:

compiler.js?7e34:466 Uncaught Error: Can't resolve all parameters for AppModule: (?). at syntaxError (eval at (app.bundle.js:1852), :684:34) at CompileMetadataResolver._getDependenciesMetadata (eval at (app.bundle.js:1852), :15765:35) at CompileMetadataResolver._getTypeMetadata (eval at (app.bundle.js:1852), :15600:26) at CompileMetadataResolver.getNgModuleMetadata (eval at (app.bundle.js:1852), :15399:24) at JitCompiler._loadModules (eval at (app.bundle.js:1852), :33760:87) at JitCompiler._compileModuleAndComponents (eval at (app.bundle.js:1852), :33721:36) at JitCompiler.compileModuleAsync (eval at (app.bundle.js:1852), :33637:37) at CompilerImpl.compileModuleAsync (eval at (app.bundle.js:1864), :245:49) at PlatformRef.bootstrapModule (eval at (app.bundle.js:229), :5646:25) at eval (eval at (app.bundle.js:827), :76:53)

app.ts

platformBrowserDynamic().bootstrapModule(AppModule);

app.module.ts

import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {UpgradeModule} from '@angular/upgrade/static';

@NgModule({
imports: [
BrowserModule,
UpgradeModule
]
})
export class AppModule {
constructor(private upgrade: UpgradeModule) {
}

ngDoBootstrap() {
this.upgrade.bootstrap(document.documentElement, ['myApp']);
}
}

tsconfig.json

{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "commonjs",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}

我正在使用 webpack。这是我的配置的一部分:

resolve: {
extensions: ['.js', '.ts'],
alias: {
"@angular/upgrade/static": "@angular/upgrade/bundles/upgrade-static.umd.js"
}
},

module: {
rules: [
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: '/node_modules'
},

最佳答案

就您共享的代码而言,一切似乎都井井有条。不过,您可能正在使用另一个与 Angular 的装饰器冲突的注解库。例如,如果您使用 angular-ts-decorators肯定会出现这样的问题。

如果是这种情况 - 删除其他注释库(无论如何现在应该是多余的)并改用 Angular 的注释。

关于angular - 无法解析应用程序模块的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47512794/

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