How do I fix eslint createRequire is not a function in Atom Editor?
Asked Answered
V

2

10

I had a difficult time tracking this down, so I'm posting to help others who search for a similar error.


I decided to set up a new project on Ubuntu 18.04 in Atom with eslint and Node.js.

ESlint, by itself, installed and ran just fine with my config extending eslint:recommended, but when I installed eslint-config-airbnb-base and changed my config to extend airbnb-base, I started getting an error in Atom and it would not parse my files.

Error while running ESLint: createRequire is not a function.

Removing airbnb and relying on eslint-plugin-import gave a similar error:

Error while running ESLint: Failed to load plugin 'import' declared in '.eslintrc.yaml': createRequire is not a function.

However, running eslint on the command-line worked fine.

Variegate answered 14/7, 2020 at 21:0 Comment(0)
V
17

This is a compatibility issue.

This change to eslint removed a polyfill that supported node versions below v10.12.0

I was running Atom 1.45.0, which uses node v10.11.0. Running eslint from the command line worked because I have node v12.18.2 installed there.

So you have two of options to fix the issue:

  1. Upgrade your Atom Editor (at the time of writing, version 1.49.0 is the latest, which uses node version v12.0.0). If that's not possible for you then...
  2. Downgrade eslint to version 6.8.0 (the last release before 7.0.0). This version still contains the polyfill for createRequire.
Variegate answered 14/7, 2020 at 21:0 Comment(1)
Thank you very much. Second option worked perfectly for me.Margaretamargarete
P
1

hello you can easily fix these issue. make sure to check in the terminal the node version you have installed if it's outdated then update the node using node version manager in the terminal,type the command $ nvm install node 14.15.0 current lts version of node is 14.15.0.once you install lts version of node $node -v ..14.15.0 $npm -v ..6.7.0 now start the development server, $npm start

these time it won't show any error

Politi answered 30/10, 2020 at 15:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.