Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

406
Views
babel node SyntaxError: Invalid or unexpected token

I am writing an ecommerce site using babel node for the import and export features of es6,and each time i try to run the site, it throws me a SyntaxError: Invalid or unexpected token

HERE IS THE SERVER FILE

 import express from 'express'
import {products} from './data'
import cors from 'cors'

const app = express()
const port = 5000


// needed files


app.use(cors())


// server app
app.get('/api/products', (req, res)=>{
    res.send(products)
})




// server
app.listen(port, ()=>{
 console.log(`server is listening on port ${port} with the link of http://localhost:5000`)
})

HERE IS THE PACKAGE.JSON FILE

{
  "name": "amazona-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon --watch backend --exec babel-node backend/server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-cli": "^6.26.0",
    "cors": "^2.8.5",
    "express": "^4.17.1"
  },
  "devDependencies": {
    "@babel/cli": "^7.14.8",
    "@babel/core": "^7.15.0",
    "@babel/node": "^7.14.9",
    "@babel/preset-env": "^7.15.0",
    "nodemon": "^2.0.12"
  }
}

AND THE BABEL.RC FILE SETTINGS

'{
"presets":[
    [
        "@babel/preset-env",
        {
            "targets":{
                "node": "current"
            }
        }
    ]
]

}'

FINALLY, THE ERR IT THROWS

> SyntaxError: Invalid or unexpected token
>     at wrapSafe (internal/modules/cjs/loader.js:979:16)
>     at Module._compile (internal/modules/cjs/loader.js:1027:27)
>     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
>     at Module.load (internal/modules/cjs/loader.js:928:32)
>     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
>     at Module.require (internal/modules/cjs/loader.js:952:19)
>     at require (internal/modules/cjs/helpers.js:88:18)
>     at Object.<anonymous> (C:\Users\Miracle\Desktop\amazona app\node_modules\core-js\stable\index.js:143:1)
>     at Module._compile (internal/modules/cjs/loader.js:1063:30)
>     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!