angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

No NgModule metadata found for 'function (){}'.

Open elvisbegovic opened this issue 9 years ago • 12 comments

Donno if it's related to https://github.com/angular/angular-cli/issues/7910 but :

- [ x] bug report -> please search issues before submitting

Versions.

Angular CLI: 1.5.0-rc.3
Node: 6.11.0
OS: win32 x64
Angular: 5.0.0-rc.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.5.0-rc.3
@angular-devkit/build-optimizer: 0.0.31
@angular-devkit/core: 0.0.20
@angular-devkit/schematics: 0.0.34
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.0-rc.3
@schematics/angular: 0.0.48
typescript: 2.5.3
webpack: 3.8.1

Repro steps.

ng build --prod --app=prod --output-path dist/fr --locale fr --bh /fr/ --i18n-format xtb --i18n-file src/locale/fr.xtb build success but on browser got error

The log given by the failure.

Browser get me : image

Desired functionality.

would be nice if this error happens durning build process,

Mention any other details that might be useful.

my package.json my .angular-cli.json

elvisbegovic avatar Oct 26 '17 10:10 elvisbegovic

I don't think it's the same as https://github.com/angular/angular-cli/issues/7910 because that one is about Universal I believe.

I haven't seen this error myself though, so I don't know what's happening here. It seems like a library doesn't have the right metadata? Perhaps that's it. Does it still happen with the latest CLI (1.5.0-rc.5)?

If it does, can you setup a minimal repro please? You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

filipesilva avatar Oct 27 '17 13:10 filipesilva

no don't have this error on rc5 and donno why, but here I couldn't find where is problem anyway will close this issue

elvisbegovic avatar Oct 27 '17 13:10 elvisbegovic

@filipesilva don't know if need open new issue but after making an "successful" ng build on browser I have this result image

thanks if any helps

elvisbegovic avatar Oct 27 '17 14:10 elvisbegovic

@istiti do you also get that error on development builds? What's the command you used to build?

filipesilva avatar Oct 27 '17 14:10 filipesilva

@filipesilva build command

    "ok": "npm run fr && npm run de",
    "fr": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --prod --app=prod --output-path dist/fr --locale fr --bh /fr/ --i18n-format xtb --i18n-file src/locale/fr.xtb",
    "de": "node --max-old-space-size=8192 ./node_modules/@angular/cli/bin/ng build --prod --app=prod --output-path dist/de --locale de --bh /de/ --i18n-format xtb --i18n-file src/locale/de.xtb",

don't have this error on dev

elvisbegovic avatar Oct 27 '17 14:10 elvisbegovic

Can you try those commands with sourcemap turned on --sm please? That should give you a better error message and maybe a hint on what's breaking.

filipesilva avatar Oct 27 '17 15:10 filipesilva

In case anyone else find this article like i just did. It turned out for me it was because in my main.ts i had: const platform = platformBrowserDynamic(); platform.bootstrapModule(AppModule);

Changing this to: platformBrowserDynamic().bootstrapModule(AppModule);

Resolved my problem.

jbiesta avatar Mar 23 '18 14:03 jbiesta

thanks @jbiesta. it reslove my problem.

shukrikhalid avatar Apr 25 '18 06:04 shukrikhalid

That fixed it for me too. That's silly!!

Luis-DevOps avatar Aug 20 '18 20:08 Luis-DevOps

This unfortunately didn't fix the problem for me, I have explained in details the problem on this stackoverflow question, in hope it was not a bug but it appears to be one: https://stackoverflow.com/questions/52892251/bootstrap-multiple-or-single-modules-based-on-url-in-main-ts

Ruud-cb avatar Oct 30 '18 13:10 Ruud-cb

I had a route definition like this in my project

export const appRoutes: Routes = [
  {path: 'main', component: MainComponent},
  {path: 'confirmation', component: ConfirmationPageComponent},
  {path: 'error', component: ErrorComponent},
];

export const appRouting = RouterModule.forRoot(appRoutes, {useHash: true});

Which I imported into app.module.ts like this:

imports: [
  appRouting,
],
...

No need to mention, this is bad beginner style. Anyway, worked in Angular 5, but didn't in 7.

dloehmann avatar Jan 23 '19 20:01 dloehmann

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.