2017-11-27 28 views
5

Tôi đang cố gắng chạy một ứng dụng lai với góc 1,6 và 5. Hướng dẫn khởi động thủ công đã hoạt động. Ngay sau khi tôi đã cố gắng để bootstrap một ứng dụng lai, tôi nhận được lỗi sau:Không thể giải quyết các thông số cho mô-đun ứng dụng

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

Tôi đang sử dụng webpack. Đây là một phần của cấu hình của tôi:

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' 
     }, 

Trả lời

0

Theo mã bạn đã chia sẻ mọi thứ dường như theo thứ tự. Nó có thể là mặc dù, rằng bạn đang sử dụng một thư viện chú thích khác đó là xung đột với trang trí của Angular. Ví dụ nếu bạn đang sử dụng angular-ts-decorators nó chắc chắn sẽ gây ra một vấn đề như vậy.

Nếu trường hợp này xảy ra - hãy xóa thư viện chú thích khác (thư viện này bây giờ sẽ không cần thiết) và sử dụng chú thích của Angular thay thế.

Các vấn đề liên quan