Unexpected token import in NextJS
See original GitHub issueI am using the plugin in NextJs in one of the component like below:
import Swiper from 'react-id-swiper';
import SwiperCSS from 'react-id-swiper/src/styles/scss/swiper.scss';
And getting this error :
C:\code\my-next\node_modules\react-id-swiper\lib\ReactIdSwiper.js:11
import React, { Component } from 'react';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\code\my-next\node_modules\react-id-swiper\lib\index.js:1:80)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Next.js SyntaxError "Unexpected token 'export'" - Stack Overflow
So the dependency in node_modules folder exports a function using ES6 import/export module. The code will throw error when it running in ...
Read more >SyntaxError: Unexpected token '<' - NextJS SVG doesnt work ...
SyntaxError : Unexpected token '<' - NextJS SVG doesnt work. ... Svgs that I import from a local folder work, but the error...
Read more >Fixing "SyntaxError: Unexpected token 'export'" with NextJS
Fixing “SyntaxError: Unexpected token ”export”” with NextJS. I ran into an error when trying to use reactgrid with NextJS. The error was
Read more >[Solved] SyntaxError: Unexpected token '.' Jest Error for Next.js ...
SyntaxError : Unexpected token '.' 2 | import Image from 'next/image' 3 | > 4 | import styles from '@/pages/index.module.css'
Read more >Error compiling on code that didn't change : r/nextjs - Reddit
pages/_app.tsx:3:12 Syntax error: Unexpected token, expected "from" 1 | import { config } from "@fortawesome/fontawesome-svg-core"; ...
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 FreeTop 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
Top GitHub Comments
Same here. Defining Component
Using component as
Error log
+1