- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在尝试使用 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/
我有一个包含几个模块的程序,比如:moduleA、moduleB 和 moduleC。 而且我还有一个头文件 debug_flags.h 我在其中定义了三个宏: #define DEBUG_MODUL
我是一名优秀的程序员,十分优秀!