question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:closed
  • Created 4 years ago
  • Reactions:12
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

9reactions
akshaypatidar455commented, Sep 14, 2019

please off the angular IVY form tsconfig.spec.json “angularCompilerOptions”: { “enableIvy”: false }

and also form tsconfig.app.json “angularCompilerOptions”: { “enableIvy”: false }

3reactions
petebacondarwincommented, Jul 18, 2019

Running npm run ivy-ngcc -l debug gives us the answer:

Debug: Invalid entry-point /Users/pete/dev/tmp/test-app/node_modules/@nguniversal/express-engine. It is missing required dependencies:
 - fs

ngcc doesn’t know about fs (it doesn’t exist in the node_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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to make Angular Ivy + Angular Universal work?
I'm having an error when I try to have Ivy + Angular Universal in my project. I only have this error when I...
Read more >
Ahead-of-time (AOT) compilation - Angular
It represents the metadata as best it can and records errors when it detects a metadata syntax violation. 2, code generation, In this...
Read more >
Angular IVY Issues - Errors that disappear after restart of "ng ...
I am running the dev-server with ng serve and every once in a while the compiler would puke out like 20 messages that...
Read more >
Angular Ivy
Ivy is the code name for Angular's next-generation compilation and rendering pipeline. With the version 9 release of Angular, the new compiler and...
Read more >
Angular Universal: Complete Practical Guide
We will then write step-by-step our own Angular Universal Express Server from ... and those get shown in the search results with no...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found