Can't get AppServerModuleNgFactory from main.js bundle
See original GitHub issue🐞 Bug report
What modules are related to this issue?
- aspnetcore-engine
- builders
- common
- express-engine
- hapi-engine
- module-map-ngfactory-loader
Is this a regression?
Yes, the previous version in which this bug was not present was: 8.**Description
After Angular and Angular Universal updates can’t get AppServerModuleNgFactory
from main.js bundle to render Angular to string and to make some our magic:).
We have such code in our server.ts now and before v9 update
const { AppServerModuleNgFactory, renderModuleFactory } = require('./dist/server/main');
but angular’s builder can’t resolve the path, all folders stay like it was
Also, I noticed that the main.js bundle doesn’t export AppServerModuleNgFactory
and in the previous version it was.
🔬 Minimal Reproduction
My server.ts:
import 'zone.js/dist/zone-node';
import * as express from 'express';
import * as fs from 'fs';
import { ngExpressEngine } from '@nguniversal/express-engine';
import { AppServerModule, renderModuleFactory } from '../src/main.server';
import { replaceAngularBundles } from './shared/utils';
/* does'n work */
const { AppServerModuleNgFactory } = require('./dist/server/main');
/* does'n work */
const server = express();
const template = fs.readFileSync('browser/index.html').toString();
const port = process.env.PORT || 4000;
server.engine('html', ngExpressEngine({
bootstrap: AppServerModule,
}));
server.get('*', (req, res) => renderModuleFactory(AppServerModuleNgFactory, {
url: req.url,
document: template,
extraProviders: [
{ provide: 'request', useFactory: () => req, deps: [] },
]
}).then(html => res.send(replaceAngularBundles(html))));
server.listen(port, () => {
console.log(`Node Express server listening on http://localhost:${ port }`);
});
export * from '../src/main.server';
run command:
ng run project-name:server:production
🔥 Exception or Error
ERROR in ./server/server.ts
Module not found: Error: Can't resolve './dist/server/main' in '/home/dmitry/WebstormProjects/fishbowl-web/server'
@ ./server/server.ts 10:22-52
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 9.1.7
Node: 12.16.1
OS: linux x64
Angular: 9.1.9
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Ivy Workspace: Yes
Package Version
--------------------------------------------------------------------
@angular-devkit/architect 0.901.7
@angular-devkit/build-angular 0.901.7
@angular-devkit/build-optimizer 0.901.7
@angular-devkit/build-webpack 0.901.7
@angular-devkit/core 9.1.7
@angular-devkit/schematics 9.1.7
@angular/cdk 9.2.4
@angular/cli 9.1.7
@angular/http 7.2.16
@angular/material 9.2.4
@ngtools/webpack 9.1.7
@nguniversal/common 9.1.1
@nguniversal/express-engine 9.1.1
@nguniversal/module-map-ngfactory-loader 9.0.0-next.9
@schematics/angular 9.1.7
@schematics/update 0.901.7
rxjs 6.5.5
typescript 3.7.5
webpack 4.42.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:9
Top Results From Across the Web
AppServerModuleNgFactory is not being built - Stack Overflow
When I debug the generated main.js I cannot find that class in the file at all. Here is my build script ng build...
Read more >an adventure. Add angular universal support to… - Medium
Having upgraded my angular application to angular 7, the next most important thing is to get it running with angular universal.
Read more >Angular Universal: Complete Practical Guide
This new application when built is going to build a main.bundle.js file, and that is the Universal bundle. This bundle contains essentially ...
Read more >main.jsbundle does not exist - YouTube
Make sure you're running a packager server or have include a . jsbundle file in your application bundle. If you are getting this...
Read more >The beginner's guide to Angular Universal - David East
To get your code running on a server you need a universal bundle. ... This indepent solution gives you basic DOM support, but...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@DmitrySobolevski, that comment doesn’t apply for Ivy.
We should update that comment.
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.