x)- [x] bug report -> please search issues before submitting
- [ ] feature request
x)- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [x] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Angular CLI: 6.2.1
Node: 8.11.2
OS: darwin x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker
@angular-devkit/architect 0.8.1
@angular-devkit/build-angular 0.8.1
@angular-devkit/build-ng-packagr 0.8.1
@angular-devkit/build-optimizer 0.8.1
@angular-devkit/build-webpack 0.8.1
@angular-devkit/core 0.8.1
@angular-devkit/schematics 0.8.1
@angular/cdk 6.4.7
@angular/cli 6.2.1
@angular/flex-layout 6.0.0-beta.18
@angular/material 6.4.7
@angular/pwa 0.8.1
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.2.1
@schematics/angular 0.8.1
@schematics/update 0.8.1
ng-packagr 4.1.1
rxjs 6.3.2
typescript 2.9.2
webpack 4.18.0
I use universal-starter, only change one line in angular.json:
"server": {
"configurations": {
"production": {
"bundleDependencies": "all", <= added
...
$ git clone -b issue-error-with-bundleDependencies [email protected]:clarkorz/universal-starter.git
$ cd universal-starter
$ yarn install
$ yarn build:ssr
$ yarn serve:ssr
md5-973735f398d017ee357994375af537ac
Error: No NgModule metadata found for '[object Object]'.
at NgModuleResolver.resolve (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:11962:27)
at CompileMetadataResolver.getNgModuleMetadata (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:10604:47)
at JitCompiler._loadModules (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:23914:55)
at JitCompiler._compileModuleAndComponents (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:23895:40)
at JitCompiler.compileModuleAsync (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@angular/compiler/bundles/compiler.umd.js:23855:41)
at CompilerImpl.compileModuleAsync (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js:195:35)
at /Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@nguniversal/express-engine/bundles/express-engine.umd.js:95:25
at new ZoneAwarePromise (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/zone.js/dist/zone-node.js:891:29)
at getFactory (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@nguniversal/express-engine/bundles/express-engine.umd.js:81:12)
at View.engine (/Users/wangshuo/Documents/GitHub/universal-starter/node_modules/@nguniversal/express-engine/bundles/express-engine.umd.js:60:13)
bundleDependencies=all should work as same as bundleDependencies=none.
No.
I think what's happening here, is that you have 2 instances of Angular providers running in parallel.
One in the server.bundle javascript files since it's being bundled and another which is being required from the server.js
//cc @vikerman
Is it related to https://github.com/angular/angular-cli/issues/8616 ?
It seems it is a duplicate of #8616.
Have a repro. First need to figure out why JitCompiler is getting involved at all since we pass in the NgFactory to the express engine.
@vikerman Any update on this issue or workaround? I'm running into it with latest Angular CLI and this seems to be a hard blocker atm.
I'm running against the same problems.
The workaround of #8616 also didn't seem to work (optimization: false)
@vikerman @MarkPieszak, would you have a look?
@mgechev its related to https://github.com/angular/angular-cli/issues/8616 which was opened on Nov 23, 2017 but still not fixed.
On it (again). Investigating the root cause.
@vikerman
Hello,
I don't want to be annoying but did you make any progress?
I'm at a point where we really need it. So my plan was to bundle it myself with webpack.
So I could avoid the bundleDependencies=all. But ofcourse this also causes the same problem.
No NgModule metadata found for '[object Object]'.
I tried to debug it a bit, but I'm not knowable of the internal workings of Angular itself.
So I have no clue where to start. And after searching the net I stumbled on this issue 'again'.
@vikerman
I tried to debug some stuff.
And I'm probably already going to say stuff you already know.
When using bundleDependencies=all this check returns false.
I have no idea why. When enabling or disabling bundleDependencies the result of
Object.getPrototypeOf(moduleOrFactory) seemed to be the 'same'.
I removed the check locally to see if it would magically work. But it seems we then have a whole bunch of other errors. So I assume the generated webpack bundle is 'wrong'. My knowledge of webpack is also to limited to say something useful (I tried to compare the bundles, but I couldn't really make much of it)
We were ending up with two copies of Angular due to the bundling setup we have for express-engine. We think we finally have a solution(See PR above) and turning on bundleDependencies on by default for version 8.0 of @nguniversal/express-engine. Still end up with a dist/server.js and dist/server/main.js (and dist/server/*.js for dynamic import based lazy routes) - But that's still lot better than shipping entire node_modules.
@ErazerBrecht - We think we have a solution for version 8.0.
@vikerman
I saw the PR ;)
I'm very exited to test it out.
Thx for update!
Enjoy your weekend!
Was this fixed with 8.2 ?
The new 8.x versions of @nguniversal/express-engine schematics creates a setup which avoid this issue.
If you are upgrading to 8.x version please follow https://github.com/angular/universal/blob/master/docs/v8-upgrade-guide.md
Would it work with ASP. Net/.Net Core? Can you please add instructions for that in readme docs?
@naveedahmed1, yeah this should also work for the .net implementation. You鈥檇 need to export ngAspnetCoreEngine from main.server.ts.
Closing this issue as it should be solved as per @vikerman鈥檚 comment.
If the problem persists after upgrading, please open a new issue, provide a simple repository reproducing the problem, and describe the difference between the expected and current behavior.
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._
Most helpful comment
@ErazerBrecht - We think we have a solution for version 8.0.