avatarPhil Andrews

Summary

The web content provides a solution for fixing the ESLint TypeError "createRequire is not a function" by updating Node.js to a compatible version using Node Version Manager (NVM).

Abstract

The article addresses a common issue encountered by developers using ESLint, specifically the TypeError "createRequire is not a function." It explains that this error is often related to an outdated version of Node.js and provides a step-by-step guide to resolve the issue. The solution involves installing Node Version Manager (NVM) to manage Node.js versions. The article instructs users to install NVM via a cURL command, set a default Node.js version compatible with ESLint 7+ (Node 10.12.0 or higher), and verify the installation and version change. The recommended Node.js version in the guide is 12.14.1. The article concludes by suggesting an alternative to manually searching through CloudWatch logs for simple issues by using a tool named Twig.

Opinions

  • The author assumes that readers are familiar with command-line operations and tools like cURL and NVM.
  • There is an emphasis on the importance of using a compatible Node.js version with ESLint to avoid errors.
  • The article promotes the use of NVM for its ease of managing multiple Node.js versions.
  • The recommendation of Twig implies that the author values efficiency and productivity tools for developers.

How To Fix: Error — ESLint TypeError createRequire is not a function

Check your Node version.

As of ESLint 7+ you need to be running Node 10.12.0 or higher.

First get Node Version Manager (NVM) by running the following command:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Ensure that nvm was installed correctly with nvm --version.

Then set your default systemwide Node version by running the following command.

nvm alias default 12.14.1

Check to make sure Node was set correctly by running:

node -v

It should print out 12.14.1

Done.

Stop digging through CloudWatch logs for simple stuff. Checkout Twig instead…

Programming
Nodejs
Node
Recommended from ReadMedium