0

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 ?

TerrorBight
  • 334
  • 4
  • 23
  • Does that help? https://stackoverflow.com/questions/43168486/unexpected-token-import-error-with-angular4-universal-ng-bootstrap – David Dec 07 '17 at 09:49
  • The above link seems more complicated than what it should be and is inconclusive. It's a fairly simple requirement - the only complexity seems to be (a) it's es6 code being run which node doesn't seem to handle well (b) is there anything 'special' about it running under Windows – TerrorBight Dec 07 '17 at 14:27

0 Answers0