Ivy + Angular universal error
See original GitHub issue🐞 bug report
angular/*@8.1.0 (Ivy engine enabled)
Is this a regression?
It works with Ivy disabled.
Description
Ivy + Angular Universal doesn’t seems to work
🔬 Minimal Reproduction
1. New project with Ivy
ng new test-angular --enableIvy
2. Add Angular Universal
ng add @nguniversal/express-engine --clientProject test-angular
3. When I do ng build I get an error
ERROR in Node does not exist: "path_to/node_modules/@nguniversal/express-engine"
Repo : https://github.com/Palapapaa/test-app
🔥 Exception or Error
ERROR in Node does not exist: "path_to/node_modules/@nguniversal/express-engine"
🌍 Your Environment
Angular Version:
Angular CLI: 8.1.0
Node: 10.15.3
OS: win32 x64
Angular: 8.1.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... platform-server, router
Package Version
--------------------------------------------------------------------
@angular-devkit/architect 0.801.0
@angular-devkit/build-angular 0.801.0
@angular-devkit/build-optimizer 0.801.0
@angular-devkit/build-webpack 0.801.0
@angular-devkit/core 8.1.0
@angular-devkit/schematics 8.1.0
@ngtools/webpack 8.1.0
@nguniversal/express-engine 8.1.1
@nguniversal/module-map-ngfactory-loader 8.1.1
@schematics/angular 8.1.0
@schematics/update 0.801.0
rxjs 6.4.0
typescript 3.4.5
webpack 4.35.2
Anything else relevant?
I only have this error when I use Angular in Ivy mode (when I set enableIvy to false in my tsconfig.app.json I can successfully build my app).
If I delete these lines in main.server.ts file (a file generated in step 2)
export { ngExpressEngine } from "@nguniversal/express-engine";
export { provideModuleMap } from "@nguniversal/module-map-ngfactory-loader";
The commands ng build, ng serve works but I still can use SSR (npm run serve:ssr fails with TypeError: provideModuleMap is not a function because of the line I’ve deleted I guess …)
Thank you =)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:12
- Comments:8 (4 by maintainers)
Top GitHub Comments
please off the angular IVY form tsconfig.spec.json “angularCompilerOptions”: { “enableIvy”: false }
and also form tsconfig.app.json “angularCompilerOptions”: { “enableIvy”: false }
Running
npm run ivy-ngcc -l debug
gives us the answer:ngcc doesn’t know about
fs
(it doesn’t exist in thenode_modules
folder 🙂) so it thinks that@nguniversal/express-engine
is not valid and doesn’t try to compile it.This is a very unusual case as most Angular packages never run on the server so it would not make sense to import node.js built-in packages.
I think the fix is that we need to have an
ignore
list of modules that we assume are ignorable.