"Unexpected token import" error with Angular4 + Universal + ng-bootstrap

For those trying to understand what the solution is, you basically want to use and whitelist angular2-toaster and other modules giving this issue.

  1. if using angular-cli, use ng eject to create a webpack.config.js
  2. install the webpack-node-externals dependency via npm install and add the following lines in the webpack.config.js file

    const nodeExternals = require('webpack-node-externals');
    
    module.exports = {
      ...
      target: 'node',
      externals: [nodeExternals({
        whitelist: [
          /^@ng-bootstrap\/ng-bootstrap/,
          /^angular2\-toaster/,
        ]
      })],
      ...
    }