core: Uncaught TypeError: core_1.NgModule is not a function

I’ve done the setup according to the documentation however, I receive the following error:

Uncaught TypeError: core_1.NgModule is not a function

That shows these lines:

   /**
    * This module doesn't provide a Translate Loader, you will have to provide one for yourself
    */
   @NgModule({
       imports: [],
       declarations: [
           TranslatePipe
       ],
              exports: [
           TranslatePipe
       ]
   })

What’s the issue?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 18

Most upvoted comments

Actually I already found the solution 😃 In my case I did bootstraping of two applications: one is written on angular 1 and second is on angular 2:

import { upgradeAdapter } from './angular2/upgrade-adapter';

upgradeAdapter.bootstrap(document.body, ['ng2-app']);
upgradeAdapter.bootstrap(document.body, ['ng1-app']);

Here is ‘./angular2/upgrade-adapter’ content:

import { UpgradeAdapter } from '@angular/upgrade';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, forwardRef } from '@angular/core';
import { HttpModule } from '@angular/http';
import { TranslateModule } from 'ng2-translate/ng2-translate';
import { TranslateService } from 'ng2-translate/ng2-translate';

var adapter = new UpgradeAdapter(forwardRef(() => appModule));

angular.module('ng2-app', []);

@NgModule({
    imports: [
        BrowserModule,
        HttpModule,
        TranslateModule.forRoot()
    ]
})
class appModule {
    constructor(private translate: TranslateService) {
        translate.addLangs(['en', 'fr']);
        translate.setDefaultLang('en');
        translate.use('en');
    }
}

export const upgradeAdapter = adapter;

So, this works fine for me 😃