Dan*_*iel 8 ng-upgrade angular
我正在尝试使用角度为1.6和5的混合应用程序.手动引导有效.一旦我尝试引导混合应用程序,我就会收到以下错误:
compiler.js?7e34:466未捕获错误:无法解析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)在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']);
}
}
Run Code Online (Sandbox Code Playgroud)
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"
]
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用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'
},
Run Code Online (Sandbox Code Playgroud)
就您共享的代码而言,一切似乎都按顺序进行。不过,您可能正在使用另一个与 Angular 装饰器冲突的注释库。例如,如果您使用Angular-ts-decorators,它肯定会导致这样的问题。
如果是这种情况 - 删除其他注释库(无论如何现在应该是多余的)并使用 Angular 的注释来代替。
| 归档时间: |
|
| 查看次数: |
517 次 |
| 最近记录: |