Running Angular Universe - cannot start server

152 Views Asked by At

I am following the steps (in https://malcoded.com/posts/angular-fundamentals-universal-server-side-rendering) to setup Angular Universe - I'm retrofitting it on top of an existing Angular 2 application. I am using node/npm on Windows.

After the setup is done, the server is started via the server.js code, submitted via:-

node server.js

server.js contains the line of code:-

require("./dist-server/main.bundle")

"./dist-server/main.bundle" contains the compiled 'server' output and fails with the message

C:\Projects\xxxx\node_modules\@ng-bootstrap\ng-bootstrap\modal\modal.js:1 (function (exports, require, module, __filename, __dirname) { import { Injectable, Injector, ComponentFactoryResolver } from '@angular/core'; ^^^^^^

SyntaxError: Unexpected token import ...

I have tried running via babel-node installed via the following

npm install babel-cli --save-dev
npm install babel-preset-env --save-dev
"node_modules/.bin/babel-node" --presets env server.js

By default the babel-node command above should ignore all files under node_modules (see https://leanpub.com/setting-up-es6/read - 4.3.4.1). However the above fails within a module under node_modules

Is there something I am doing wrong ?

0

There are 0 best solutions below