Uncaught SyntaxError: Unexpected token import
See original GitHub issueFirst, I installed: npm install vue-awesome --save-dev
Then I added the following lines to main.js
, based on the readme and example:
import Icon from 'vue-awesome/src/components/Icon.vue';
Vue.component('icon', Icon);
I get this error in the browser console:
> Uncaught SyntaxError: Unexpected token import Icon.vue?7cbb:36
Am I doing something incorrect? Thx!
Issue Analytics
- State:
- Created 7 years ago
- Comments:64 (20 by maintainers)
Top Results From Across the Web
Uncaught SyntaxError: Unexpected token import - Stack ...
As long as you import your scripts (including the entrypoint to your application) using <script type="module" src="..."> it will work.
Read more >SyntaxError: Unexpected token import in Node.js | bobbyhadz
The "SyntaxError: Unexpected token import" occurs when we use the ES6 import syntax in a version of Node that doesn't support it. To...
Read more >Nodejs Uncaught SyntaxError: Unexpected token import
An unexpected token import occurs when an error message appears in the console while running a web application.
Read more >JavaScript ES6 - How to fix Unexpected token import - YouTube
This video is a short explanation on how to fix the syntax error : " Unexpected Token Import "Hint: type="module"
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jonnyparris
Nuxt’s server webpack config excludes all external modules from being transpiled in the server build. You need to whitelist vue-awesome (and it’s subpaths). Here’s how I fixed it for SSR:
Note: the first regex comes from the base nuxt server config.
I had similar (if not the same) problem, I’m using
webpack
+vue-loader
+babel
. I have a.babelrc
but withoutadd-module-exports
plugin, but adding that to my own.babelrc
didn’t do me any good. I ended up importing the dist instead, worked like a charm.Cheers, fatbrain