New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiki: stories universal rendering: Cannot find name 'AppServerModuleNgFactory' not 'LAZY_MODULE_MAP' #13385

Closed
c00 opened this Issue Jan 9, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@c00
Copy link

c00 commented Jan 9, 2019

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions

v8.11.3
6.5.0

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 6.1.5
Node: 8.11.3
OS: linux x64
Angular: 6.1.9
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.5
@angular-devkit/build-angular     0.7.5
@angular-devkit/build-optimizer   0.7.5
@angular-devkit/build-webpack     0.7.5
@angular-devkit/core              0.7.5
@angular-devkit/schematics        0.7.5
@angular/cli                      6.1.5
@angular/platform-server          6.1.10
@ngtools/webpack                  6.1.5
@schematics/angular               0.7.5
@schematics/update                0.7.5
rxjs                              6.3.3
typescript                        2.7.2
webpack                           4.9.2

Running on Ubuntu 18.04

Repro steps

  1. Follow the universal story, up to and including step 4.
  2. Try step 5.

The log given by the failure

coo@thor:~/dev/www/cirque/cirque-library$ npm run build:ssr

> cirquel-library@0.0.0 build:ssr /home/coo/dev/www/cirque/cirque-library
> npm run build:client-and-server-bundles && npm run webpack:server


> cirquel-library@0.0.0 build:client-and-server-bundles /home/coo/dev/www/cirque/cirque-library
> ng build --prod && ng run cirquel-library:server


Date: 2019-01-09T07:07:33.323Z
Hash: 0e3c6ba12126ad16a590
Time: 12638ms
chunk {scripts} scripts.8af9600ce405f4ee8475.js (scripts) 212 kB  [rendered]
chunk {0} runtime.a66f828dca56eeb90e02.js (runtime) 1.05 kB [entry] [rendered]
chunk {1} styles.1c9db16de07904d7c9fe.css (styles) 131 kB [initial] [rendered]
chunk {2} polyfills.2f4a59095805af02bd79.js (polyfills) 59.6 kB [initial] [rendered]
chunk {3} main.24795b6742be479dce8d.js (main) 581 kB [initial] [rendered]

Date: 2019-01-09T07:07:40.182Z
Hash: 530691710610f1f8f121
Time: 5232ms
chunk {main} main.js, main.js.map (main) 164 kB [entry] [rendered]

> cirquel-library@0.0.0 webpack:server /home/coo/dev/www/cirque/cirque-library
> webpack --config webpack.server.config.js --progress --colors

Hash: 9950f741fdbec97b20ee
Version: webpack 4.9.2
Time: 5035ms
Built at: 2019-01-09 14:07:45
    Asset      Size  Chunks             Chunk Names
server.js  4.74 MiB       0  [emitted]  server
Entrypoint server = server.js
  [0] ./server.ts 1.66 KiB {0} [built] [2 errors]
  [2] external "events" 42 bytes {0} [built]
  [3] external "fs" 42 bytes {0} [built]
  [4] external "timers" 42 bytes {0} [optional] [built]
  [5] external "crypto" 42 bytes {0} [built]
[211] ./src lazy namespace object 160 bytes {0} [built]
[214] external "url" 42 bytes {0} [built]
[274] external "http" 42 bytes {0} [built]
[275] external "https" 42 bytes {0} [built]
[276] external "os" 42 bytes {0} [built]
[284] external "path" 42 bytes {0} [built]
[293] external "util" 42 bytes {0} [built]
[301] external "net" 42 bytes {0} [built]
[306] external "buffer" 42 bytes {0} [built]
[363] ./src sync 160 bytes {0} [built]
    + 376 hidden modules

ERROR in /home/coo/dev/www/cirque/cirque-library/server.ts
./server.ts
[tsl] ERROR in /home/coo/dev/www/cirque/cirque-library/server.ts(28,23)
      TS2304: Cannot find name 'AppServerModuleNgFactory'.

ERROR in /home/coo/dev/www/cirque/cirque-library/server.ts
./server.ts
[tsl] ERROR in /home/coo/dev/www/cirque/cirque-library/server.ts(34,24)
      TS2304: Cannot find name 'LAZY_MODULE_MAP'.

ERROR in /home/coo/dev/www/cirque/cirque-library/src/app/bg-image.directive.spec.ts
[tsl] ERROR in /home/coo/dev/www/cirque/cirque-library/src/app/bg-image.directive.spec.ts(5,23)
      TS2554: Expected 1 arguments, but got 0.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! cirquel-library@0.0.0 webpack:server: `webpack --config webpack.server.config.js --progress --colors`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the cirquel-library@0.0.0 webpack:server script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/coo/.npm/_logs/2019-01-09T07_07_45_824Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! cirquel-library@0.0.0 build:ssr: `npm run build:client-and-server-bundles && npm run webpack:server`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the cirquel-library@0.0.0 build:ssr script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/coo/.npm/_logs/2019-01-09T07_07_45_835Z-debug.log

Desired functionality

The references in the suggested server.ts file as described in the wiki, step 4 should be correct. The modules AppServerModuleNgFactory and LAZY_MODULE_MAP have no import, so the TS compiler fails.

Mention any other details that might be useful

Vscode already complains in the editor that these 2 names cannot be found. And when running the sugggested commands, the ng cli also concludes these names are unknown.

(I've tried finding the correct references somewhere, but apparently I don't have the know-how to fix this.)

@alan-agius4

This comment has been minimized.

Copy link
Collaborator

alan-agius4 commented Jan 9, 2019

Hi, the wiki documentation is deprecated and the new documents can be found here: https://angular.io/guide/universal

There is also a PR to improve this documentation angular/angular#26444

The missing part in your code is;

const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require('./server/main');

@alan-agius4 alan-agius4 closed this Jan 9, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment