Skip to content

Ivy + Angular universal error #31522

Closed
Closed

Description

@guillaume-moreau

🐞 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 =)

Activity

  1. added this to the needsTriage milestone on Jul 12, 2019
  2. guillaume-moreau commented on Jul 17, 2019

    @guillaume-moreau
    ContributorAuthor

    Hi guys !

    Any news ? :)

    Is this an Ivy bug ?

  3. vikerman commented on Jul 18, 2019

    @vikerman
    Contributor

    Looks like an ngcc issue. Will follow up. Thanks

  4. petebacondarwin commented on Jul 18, 2019

    @petebacondarwin
    Contributor

    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.

  5. omahjoub commented on Jul 23, 2019

    @omahjoub

    Hi all, same problem here, is there any planned fix to this?

    Node: 12.6.0
    OS: darwin x64
    Angular: 8.1.2
    ... cli, common, compiler, compiler-cli, core, forms
    ... language-service, platform-browser, platform-browser-dynamic
    ... router
    
    Package                           Version
    -----------------------------------------------------------
    @angular-devkit/architect         0.801.2
    @angular-devkit/build-angular     0.801.2
    @angular-devkit/build-optimizer   0.801.2
    @angular-devkit/build-webpack     0.801.2
    @angular-devkit/core              8.1.2
    @angular-devkit/schematics        8.1.2
    @ngtools/webpack                  8.1.2
    @schematics/angular               8.1.2
    @schematics/update                0.801.2
    rxjs                              6.4.0
    typescript                        3.4.5
    webpack                           4.35.2
    
  6. petebacondarwin commented on Jul 23, 2019

    @petebacondarwin
    Contributor

    No fix created yet... It is in the pipeline.

  7. JoostK commented on Jul 26, 2019

    @JoostK
    Member

    We can leverage require('module').builtinModules to know which modules to ignore :-)

  8. self-assigned this
    on Jul 27, 2019
  9. added a commit that references this issue on Aug 1, 2019
    506d314
  10. added a commit that references this issue on Sep 6, 2019
    132704e
  11. akshaypatidar455 commented on Sep 14, 2019

    @akshaypatidar455

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

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

  12. angular-automatic-lock-bot commented on Oct 15, 2019

    @angular-automatic-lock-bot

    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.

  13. locked and limited conversation to collaborators on Oct 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions