question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
oleztcommented, Nov 8, 2017

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

1reaction
IAMtheIAMcommented, Aug 9, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack: Unexpected token import - Stack Overflow
When I require the "html-webpack-plugin" , and exporting the object with "module.exports" it works fine but I'm trying to write this in ES6....
Read more >
Upgrade Angular 4 app to Angular 5 with Visual Studio 2017
Webpack uses AotPlugin to compile the Angular 4 apps, now Webpack no longer uses Aotplugin for Angular 5. It now uses AngularCompilerPlugin.
Read more >
Optimizing an Angular App with the AoT compilation
To do this, we used the webpack AotPlugin in the production configuration (which allows us ... SyntaxError: Unexpected token { at exports.
Read more >
typescript syntaxerror: unexpected token 'export' - You.com
So the dependency in node_modules folder exports a function using ES6 import/export module. The code will throw error when it running in browser...
Read more >
Webpack lesson - Uncaught SyntaxError: Unexpected token ...
Why do I get "Uncaught SyntaxError: Unexpected token import"? Compiling works ok.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found