I get some error use server-side-rendering after enable ivy render,like this:
Node Express server listening on http://localhost:4000
Error: You must pass in a NgModule or NgModuleFactory to be bootstrapped
at View.engine (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:44667:23)
at View.render (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:130197:8)
at tryRender (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:127096:10)
at Function.render (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:127048:3)
at ServerResponse.render (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:136967:7)
at app.get (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:138:9)
at Layer.handle [as handle_request] (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:128820:5)
at next (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:128568:13)
at Route.dispatch (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:128543:3)
at Layer.handle [as handle_request] (C:\Users\Administrator\Desktop\none-ssr\dist\server.js:128820:5)
environments:
Angular CLI: 8.0.0
Node: 10.15.3
OS: win32 x64
Angular:
Package Version
------------------------------------------------------
@angular-devkit/architect 0.800.0
@angular-devkit/core 8.0.0
@angular-devkit/schematics 8.0.0
@schematics/angular 8.0.0
@schematics/update 0.800.0
rxjs 6.4.0
Thanks for any answers!
This seems like a bug but we'll need to look at a reproduction to find and fix the problem. 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.
This might be related to your directory structure so its really important to get an accurate repro to diagnose this.
Hi actually thinking about it I don鈥檛 think SSR is supported yet under Ivy, @vikerman can you please confirm?
@alan-agius4 Thanks for you reply on busy time, then I create a minium repro-app on https://github.com/1227233860/repro-app. I think it will help you reappear the problem.
Using platform-server should continue to work with Ivy. Will take a look at the repo.
@vikerman any updates on this issue? I have the same problem
@vdumbrav As far as I know, the problem has not been solved.
@1227233860, @alan-agius4 is looking into this. We're aware of the issue and it's with a high priority.
@mgechev thanks for answer
Hi all, I am currently looking into Universal and Ivy.
The issue above that the the generated server.ts is not compatible with Ivy. The main reason being that in Ivy there are no longer ngFactories generated.
Another thing to point out is that for Ivy it required to use bundleDependencies which will be turned on by default in CLI version 9. Users opting out of bundleDependencies will need to run ivy-ngcc manually. The later requirement is needed because we need to transform npm view engine libraries into something ivy compatible runtime code.
So a working server.ts shouldn't contain ngfactories references
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import * as express from 'express';
import {join} from 'path';
// Express server
const app = express();
const PORT = process.env.PORT || 4000;
const DIST_FOLDER = join(process.cwd(), 'dist/browser');
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {AppServerModule, ngExpressEngine} = require('./dist/server/main');
// Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
app.engine('html', ngExpressEngine({
bootstrap: AppServerModule
}));
app.set('view engine', 'html');
app.set('views', DIST_FOLDER);
// Example Express Rest API endpoints
// app.get('/api/**', (req, res) => { });
// Server static files from /browser
app.get('*.*', express.static(DIST_FOLDER, {
maxAge: '1y'
}));
// All regular routes use the Universal engine
app.get('*', (req, res) => {
res.render('index', { req });
});
// Start up the Node server
app.listen(PORT, () => {
console.log(`Node Express server listening on http://localhost:${PORT}`);
});
Closing as it should have been addressed in the above Pr.
It does not work for me,
I use
npx @angular/cli@next new abcd --routing=true --skipTests=true --style=scssnpx @angular/cli@next add @nguniversal/express-engine --clientProject abcdnpm run build:ssr && npm run serve:ssr@alan-agius4 please check
Hi, you need to use @nguniversal/express-engine@next
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
@1227233860, @alan-agius4 is looking into this. We're aware of the issue and it's with a high priority.