angular-webpack-starter: Universal crashes in AOT mode
hello I am getting the following error when i try to compile universal.
> nodemon dist/server/index.js
[nodemon] 1.10.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /Projects/SL/dist/**/*
[nodemon] starting `node dist/server/index.js`
/Projects/SL/node_modules/@angular/platform-browser/src/browser/browser_adapter.js:13
import { setRootDomAdapter } from '../dom/dom_adapter';
^^^^^^
SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.23 (/Projects/SL/dist/server/index.js:6:14071)
at t (/Projects/SL/dist/server/index.js:1:177)
[nodemon] app crashed - waiting for file changes before starting...
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 40 (17 by maintainers)
@qdouble on running
npm run universal:aot
and then navigating tolocalhost:8000
, I am getting below error although UI renders properly but it is failing on server@privettoli Angular 4 will be released in few days with a completely new server side rendering. I suggest that you way for this release and migrate to it. Angular Universal will be removed as it will be merged to Angular core
@fmoessle Universal isn’t fully compatible with material unless you roll back to alpha 8, you can track the issue here: https://github.com/angular/material2/issues/308
this isn’t a universal so much as it’s a problem with how AoT works, how angular packages their code, and webpack. for externals on the server you need to make sure it bundles any angular code so packages that start with
@angular
,angular2-
,ng2-
,ng-
, andangular-
I added AoT support to universal-starter by making sure every lib on the node side is included to ensure the requires are all correct
Material doesn’t work with universal