Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No NgModule metadata found for '[object Object]' #908

Closed
IAMtheIAM opened this issue Aug 26, 2016 · 16 comments
Closed

No NgModule metadata found for '[object Object]' #908

IAMtheIAM opened this issue Aug 26, 2016 · 16 comments

Comments

@IAMtheIAM
Copy link

IAMtheIAM commented Aug 26, 2016

When I try to navigate to the +detail component, it fails and throws an error instantly: What could cause this?
EXCEPTION: Error: Uncaught (in promise): No NgModule metadata found for '[object Object]'.

vendors.bundle.js?42d2f33…:58505 Error: Uncaught (in promise): No NgModule metadata found for '[object Object]'.
    at resolvePromise (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17687:32)
    at http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17664:14
    at ZoneDelegate.invoke (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17461:29)
    at Object.onInvoke (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:56362:41)
    at ZoneDelegate.invoke (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17460:35)
    at Zone.run (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17354:44)
    at http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17720:58
    at ZoneDelegate.invokeTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17494:38)
    at Object.onInvokeTask (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:56353:41)
    at ZoneDelegate.invokeTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17493:43)
    at Zone.runTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17394:48)
    at drainMicroTaskQueue (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17626:36)
  -------------   Elapsed: 1 ms; At: Fri Aug 26 2016 14:15:08 GMT-0700 (US Mountain Standard Time)   -------------  
    at Object.onScheduleTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17067:23)
    at ZoneDelegate.scheduleTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17471:50)
    at Zone.scheduleMicroTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17408:40)
    at scheduleResolveOrReject (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17718:15)
    at resolvePromise (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17682:22)
    at http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17664:14BrowserDomAdapter.logError @ vendors.bundle.js?42d2f33…:58505ExceptionHandler.call @ vendors.bundle.js?42d2f33…:51659next @ vendors.bundle.js?42d2f33…:38610schedulerFn @ vendors.bundle.js?42d2f33…:40646SafeSubscriber.__tryOrUnsub @ vendors.bundle.js?42d2f33…:1305SafeSubscriber.next @ vendors.bundle.js?42d2f33…:1254Subscriber._next @ vendors.bundle.js?42d2f33…:1204Subscriber.next @ vendors.bundle.js?42d2f33…:1168Subject._finalNext @ vendors.bundle.js?42d2f33…:3994Subject._next @ vendors.bundle.js?42d2f33…:3986Subject.next @ vendors.bundle.js?42d2f33…:3943EventEmitter.emit @ vendors.bundle.js?42d2f33…:40634onError @ vendors.bundle.js?42d2f33…:41373onHandleError @ vendors.bundle.js?42d2f33…:56383ZoneDelegate.handleError @ polyfills.bundle.js?42d2f33…:17465Zone.runGuarded @ polyfills.bundle.js?42d2f33…:17371_loop_1 @ polyfills.bundle.js?42d2f33…:17637drainMicroTaskQueue @ polyfills.bundle.js?42d2f33…:17644
polyfills.bundle.js?42d2f33…:17613 Unhandled Promise rejection: No NgModule metadata found for '[object Object]'. ; Zone: angular ; Task: Promise.then ; Value: BaseException {message: "No NgModule metadata found for '[object Object]'.", stack: "Error: No NgModule metadata found for '[object Obj…olyfills.bundle.js?42d2f33b7728a1e23e8f:17626:36)"} Error: No NgModule metadata found for '[object Object]'.
    at new BaseException (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:3795:23)
    at NgModuleResolver.resolve (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:37056:23)
    at CompileMetadataResolver.getNgModuleMetadata (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:36252:47)
    at RuntimeCompiler._compileComponents (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:47637:47)
    at RuntimeCompiler._compileModuleAndComponents (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:47559:37)
    at RuntimeCompiler.compileModuleAsync (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:47536:21)
    at ModuleBoundCompiler.compileModuleAsync (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:47908:31)
    at MergeMapSubscriber.project (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:43164:119)
    at MergeMapSubscriber._tryNext (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60305:27)
    at MergeMapSubscriber._next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60295:18)
    at MergeMapSubscriber.Subscriber.next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:1168:18)
    at ScalarObservable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:43442:24)
    at ScalarObservable.Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:62)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeMapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60270:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Object.subscribeToResult (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:2201:27)
    at MergeMapSubscriber._innerSub (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60315:38)
    at MergeMapSubscriber._tryNext (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60312:14)
    at MergeMapSubscriber._next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60295:18)
    at MergeMapSubscriber.Subscriber.next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:1168:18)
    at ScalarObservable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:43442:24)
    at ScalarObservable.Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:62)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeMapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60270:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeMapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60270:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at CatchOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:96169:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Object.subscribeToResult (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:2201:27)
    at MergeAllSubscriber._next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:33241:42)
    at MergeAllSubscriber.Subscriber.next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:1168:18)
    at MapSubscriber._next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60184:26)
    at MapSubscriber.Subscriber.next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:1168:18)
    at ArrayObservable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:9845:28)
    at ArrayObservable.Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:62)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeAllOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:33219:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at FirstOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:96427:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at CatchOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:96169:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Object.subscribeToResult (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:2201:27)
    at MergeAllSubscriber._next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:33241:42)
    at MergeAllSubscriber.Subscriber.next (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:1168:18)
    at ScalarObservable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:43442:24)
    at ScalarObservable.Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:62)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeAllOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:33219:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at LastOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:96551:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at CatchOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:96169:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeMapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60270:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60156:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeMapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60270:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at Observable._subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:203:28)
    at MergeMapOperator.call (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:60270:23)
    at Observable.subscribe (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:146:38)
    at http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:176:38
    at new ZoneAwarePromise (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17736:30)
    at Observable.forEach (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:175:16)
    at http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:22594:18
    at Router.runNavigate (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:22558:16)
    at http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:22536:67
    at ZoneDelegate.invoke (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17461:29)
    at Object.onInvoke (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:56362:41)
    at ZoneDelegate.invoke (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17460:35)
    at Zone.run (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17354:44)
    at http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17720:58
    at ZoneDelegate.invokeTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17494:38)
    at Object.onInvokeTask (http://localhost:4000/vendors.bundle.js?42d2f33b7728a1e23e8f:56353:41)
    at ZoneDelegate.invokeTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17493:43)
    at Zone.runTask (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17394:48)
    at drainMicroTaskQueue (http://localhost:4000/polyfills.bundle.js?42d2f33b7728a1e23e8f:17626:36)
@rodrigoarantes
Copy link

Hi IAMtheIAM,
It could be due to missing default export in your NgModule file.
You would need to have something like.
export default class MyModule {}

@AT-SyT
Copy link

AT-SyT commented Sep 4, 2016

I am running into the same issue and I already tried to switch the modules to 'export default' but the error stays the same.

@qdouble
Copy link

qdouble commented Sep 4, 2016

...

@AT-SyT
Copy link

AT-SyT commented Sep 5, 2016

I resolved my problem.
It was a pretty subtle and stupid error caused by myself. I must have accidentally put some random characters in the RegExp of the string-replace-loader for the System.import, thus the replacement was never triggered.
After fixing this everything works as expected.

@ghost
Copy link

ghost commented Sep 8, 2016

Would you be able to provide your that fix on here. I am struggling as well and would like to compare my regex to see if it is correct. Thanks

@aminebizid
Copy link

I have the same problem
export default Ok
RegExp Ok

@IAMtheIAM
Copy link
Author

IAMtheIAM commented Sep 8, 2016

@rodrigoarantes I tried adding export default class AppModule to this file at https://github.com/AngularClass/angular2-webpack-starter/blob/5324ba628bc05a8b0b932d6214f7f89c755094d8/src/app/app.module.ts#L56, but now it gives typescript error

Module '"~/app.module"' has no exported member 'AppModule'.
[default] Checking finished with 1 errors

@aminebizid
Copy link

Don't do default class on not lazy loaded module

@PatrickJS
Copy link
Owner

ok this should help
a0f57b4
but I should probably move that logic to the routes so it's not too surprising

@aminebizid
Copy link

This is solved when using entire path of the file containing the module and not the index

@IAMtheIAM
Copy link
Author

IAMtheIAM commented Sep 21, 2016

I still get the issue. I tried adding

      {
        test: /\.ts$/,
        loader: 'string-replace-loader',
        query: {
          search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
          replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)',
          flags: 'g'
        },
        include: [helpers.root('src')]
      },

But get TypeError: Cannot supply flags when constructing one RegExp from another
If I remove the flags: 'g' then no typeerror, but same angular error
Subscriber.js:223 EXCEPTION: Uncaught (in promise): Error: No NgModule metadata found for '[object Object]'.

I'm using webpack@^2.1.0-beta.25, which doesn't allow "preloaders", instead it uses the "enforce: pre" option on the loader like this:

         // This is the preloader
         {
            test: /\.ts$/,
            enforce: 'pre',
            loader: 'string-replace-loader',
            query: {
               search: '(System|SystemJS)(.*[\\n\\r]\\s*\\.|\\.)import\\((.+)\\)',
               replace: '$1.import($3).then(mod => (mod.__esModule && mod.default) ? mod.default : mod)',
               // flags: 'g'
            },
            include: [helpers.root('./src')]
         },

@StefanRKarlsson
Copy link

@Zigzag95 You are correct, but is there any solution how to get it working with a index.ts file?

@IAMtheIAM
Copy link
Author

I'm surprised there is not a resolution to this after almost a month. Isn't there an angular official way to do this? It seems like it should be standard in webpack / angular 2 workflow.

@jussikinnula
Copy link

I have a similar starter with lazy loading, and it doesn't have the issue. Go and check it out: https://github.com/jussikinnula/angular2-mean-starter

@zeqk
Copy link

zeqk commented Oct 3, 2016

This issue is related to this #926

when you run the "npm run" in "c:\my_project" (pay attention to the casing)

throw this warning and errors

WARNING in ./~/webpack/buildin/module.js
There are multiple modules with names that only differ in casing.
This can lead to unexpected behavior when compiling on a filesystem with other case-semantic.
Use equal casing. Compare these module identifiers:
* d:\NProjects\bats-ng2-admin\string-replace-loader\index.js?{"search":"var sourceMappingUrl = extractSourceMappingUrl\\(cssText\\);","replace":"var sourceMappingUrl = \"\";","flags":"g"}!D:\NProjects\bats-ng2-admin\node_modules\webpack\buildin\module.js
    Used by 2 module(s), i. e.
    d:\NProjects\bats-ng2-admin\node_modules\string-replace-loader\index.js?{"search":"var sourceMappingUrl = extractSourceMappingUrl\\(cssText\\);","replace":"var sourceMappingUrl = \"\";","flags":"g"}!D:\NProjects\bats-ng2-admin\node_modules\punycode\punycode.js
* d:\NProjects\bats-ng2-admin\node_modules\string-replace-loader\index.js?{"search":"var sourceMappingUrl = extractSourceMappingUrl\\(cssText\\);","replace":"var sourceMappingUrl = \"\";","flags":"g"}!d:\NProjects\bats-ng2-admin\node_modules\webpack\buildin\module.js
    Used by 3 module(s), i. e.
    d:\NProjects\bats-ng2-admin\node_modules\string-replace-loader\index.js?{"search":"var sourceMappingUrl = extractSourceMappingUrl\\(cssText\\);","replace":"var sourceMappingUrl = \"\";","flags":"g"}!d:\NProjects\bats-ng2-admin\node_modules\lodash\lodash.js

Error: Uncaught (in promise): No NgModule metadata found for '[object Object]'.

And the page title is like this <%= webpackConfig.metadata.title %>

for avoid this error only need change the path to "C:\my_project" (pay attention to the casing)

@IAMtheIAM
Copy link
Author

IAMtheIAM commented Oct 3, 2016

@jussikinnula Thanks man, your repo helped my diagnose what was wrong with mine.

Turns out that angular2-template-loader cannot understand line comments inside of the routes object. During testing, I had a lot of variations commented out on one of my sub module routes, like this:

{
   path: 'detail',
   // loadChildren: () => System.import('../+detail/detail.module'),
   loadChildren: '../+detail/detail.module#DetailModule',
   // loadChildren: 'es6-promise?,[name]!../+detail/detail.module#DetailModule',
   // loadChildren: loadLazy('../+detail/detail.detailRoutes', DetailComponent)
   // loadChildren: () => System.import('../+detail/detail.module.ts')
},

But that gives many errors. Just by removing the line comments, it fixed it:

   {
      path: 'detail',
      loadChildren: '../+detail/detail.module#DetailModule',
   },

That was tricky to diagnose.

The second part of my fix was that on my typescript loader, I was using 'angular2-router-loader', but it never worked as expected. Then, I saw in your repo that you have 'angular2-router-loader?loader=system', so I tried it, and that did the trick!

So lessons:

  • add query ?loader=system to angular2-router-loader
  • don't use any line comments within routes object for sub modules loaded by angular2-router-loader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants