• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

229
Vistas
Why is ESLint complaining about a syntax error when I can run my code fine in Node? "Parsing error: Unexpected token ="

I have looked around in Stackoverflow and the ESLint docs for an answer, but most are not what I need since they pertain to React.

I am using Node v14.17.0, and ESLint v7.32.0 as a dev dependency. I have the following piece of code.

class Service {
  constructor(){
    this.numbers = [1,2,3];
  }

  doAnotherThing = () => {
    console.log("I do the thing after 100 millis", this.numbers);
  }
  
  doSomething(){
    setTimeout(this.doAnotherThing, 100);
  }
}

let service = new Service();
service.doSomething();

Simply running node test.js runs the application fine and I get the expected result printed to STDOUT.

All sounds good, let me add ESLint and the eslint config file.

{
  "env": {
      "node": true,
      "mocha": true
  },
  "extends": "eslint:recommended",
  "parserOptions": {
      "ecmaVersion": "latest"
  },
}

Now run when I run eslint on the file, I get the following error.

/test.js
  2:10  error  Parsing error: Unexpected token =

Keep in mind I am NOT using Babel or any transpiling, so do I need to specify a variable or something in the config? Why is this error happening and why does installing @babel/eslint-parser solve the issue? I am not using Babel at all. Is this a limit to ESLint or simply something I don't understand?

Using a regular method(){} does NOT work and is not the solution since I lose the this.number value. See: https://jsfiddle.net/0crpx6bv

Reading around I see a lot of React and NONE Node.js solutions. This is plain Node without Babel and not in React.

about 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda