angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

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

Open IAMtheIAM opened this issue 9 years ago • 5 comments

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)

IAMtheIAM avatar Aug 07 '17 19:08 IAMtheIAM

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

hansl avatar Aug 07 '17 21:08 hansl

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

IAMtheIAM avatar Aug 09 '17 17:08 IAMtheIAM

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

olezt avatar Nov 08 '17 12:11 olezt

Try - new AotPlugin.AotPlugin({})

dovip avatar Nov 27 '17 12:11 dovip

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.