Angular-cli: SyntaxError: Unexpected token import (import {AotPlugin} from '@ngtools/webpack')

Created on 7 Aug 2017  路  5Comments  路  Source: angular/angular-cli

Bug Report or Feature Request (mark with an x)

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

Versions.

npm -v
4.6.1

node -v
v6.10.0

webpack version 3.4.1

Repro steps.


Following the documentation readme instructions, Adding this to webpack config file causes immediate compilation error

import {AotPlugin} from '@ngtools/webpack';

The log given by the failure.

import {AotPlugin} from '@ngtools/webpack'
^^^^^^
SyntaxError: Unexpected token import
    at Object.exports.runInThisContext (vm.js:76:16)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)

Most helpful comment

Same problem. Changed it to require and then I get
new AotPlugin({
^
TypeError: AotPlugin is not a constructor

All 5 comments

The import keyword is not supported by Node. You need to use require('@ngtools/webpack').

Ok but why doesn't it say that clearly in the documentation page? Its too much to assume people will know this. Please update docs with this explanation. Thanks

Same problem. Changed it to require and then I get
new AotPlugin({
^
TypeError: AotPlugin is not a constructor

Try - new AotPlugin.AotPlugin({})

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings