Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does ESLint throw an error while using export/import statement on Node.js 12.13.0?

I have a project built on Node.js, DynamoDB and other AWS services, deployed on Serverless architecture. I also have the ESLint package installed.

I am getting the following error:

ESLint: Import and export declarations are not supported yet on Node 8.0.0. (node/no-unsupported-features)

Following are the details of my project:

Node version: 12.13.0
NPM version: 6.12.0
Serverless version: 1.40.0
ESLint: 6.8.0

I have double verified by node version of my project and my local. Both are the same (12.13.0).

I am able to use async/await but whenever I try using import/export, it gives me the error.

Following is my .eslintrc file :

{
  "extends" : [
    "eslint:recommended",
    "plugin:node/recommended"
  ],
  "plugins": [
    "promise",
    "node"
  ],
  "env"     : {
    "browser" : false,
    "node": true,
    "es6": true
  },
  "parserOptions": {
    "ecmaVersion": 9,
    "sourceType": "module",
    "impliedStrict": false
  },
  "globals" : {
  },
  "rules": {
    "no-console": 0,
    "no-unused-vars": ["error", { "vars": "all", "args": "none", "ignoreRestSiblings": false }],
    "node/no-unpublished-require": [
      "error",
      {
        "allowModules": [
          "aws-sdk"
        ]
      }
    ],
    "node/no-unsupported-features": ["error", {
      "version": 8,
      "ignores": []
    }]
  }
}
`
like image 644
user3807691 Avatar asked Nov 16 '25 11:11

user3807691


1 Answers

Just stumpled upon a similiar error.

In my case i solved it by adding the engines definition to package.json

"engines": {
    "node": ">=12.13.0"
}

I am not sure if this solves you problem but a quite similar issue can be found here.

like image 94
Lennart Lenin Olsen Avatar answered Nov 19 '25 03:11

Lennart Lenin Olsen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!