Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for es6 syntax "SyntaxError: Unexpected token export" #20

Closed
mirsahib opened this issue Dec 27, 2020 · 1 comment
Closed

support for es6 syntax "SyntaxError: Unexpected token export" #20

mirsahib opened this issue Dec 27, 2020 · 1 comment

Comments

@mirsahib
Copy link

mirsahib commented Dec 27, 2020

I am facing this error while using es6 syntax
SyntaxError: Unexpected token export
Is there any way to upgrade the babel or web pack to support es6 syntax

How to reproduce the error
create a file test.js inside root folder

import axios from "axios"
const fun = function(){
    // write your logic
}
export default fun;

error log

SyntaxError: Unexpected token export
[0]     at Module._compile (internal/modules/cjs/loader.js:723:23)
[0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
[0]     at Module.load (internal/modules/cjs/loader.js:653:32)
[0]     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
[0]     at Function.Module._load (internal/modules/cjs/loader.js:585:3)
[0]     at Module.require (internal/modules/cjs/loader.js:692:17)
[0]     at require (internal/modules/cjs/helpers.js:25:18)
[0]     at Object.<anonymous> (/home/mirsahib/Desktop/MERN_WS/example-create-react-app-express/routes/scraper.routes.js:2:27)
[0]     at Module._compile (internal/modules/cjs/loader.js:778:30)
[0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
@esausilva
Copy link
Owner

Are referring to supporting ES6 server-side (Node)? There is no Babel/Webpack config server-side on the project but you can refer to other tutorials to add support for ES6 like the ones below.

https://www.freecodecamp.org/news/how-to-enable-es6-and-beyond-syntax-with-node-and-express-68d3e11fe1ab/
https://dev.to/mixed_code/set-up-node-project-in-es6-2bla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants