DEV Community

Jen C.
Jen C.

Posted on

How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues

When get the error by running

npm run lint -w myFolder
Enter fullscreen mode Exit fullscreen mode

Error messages

Oops! Something went wrong! :(

ESLint: 9.12.0

TypeError: ObjectSchema is not a constructor
    at new Config (/node_modules/eslint/lib/config/config.js:175:24)
    at [finalizeConfig] (/node_modules/eslint/lib/config/flat-config-array.js:216:16)
    at FlatConfigArray.getConfigWithStatus (/node_modules/@eslint/config-array/dist/cjs/index.cjs:1102:55)
    at FlatConfigArray.getConfig

    ...
Enter fullscreen mode Exit fullscreen mode

Root cause

The version specified in package.json is 9.9.0, but the error log shows that the command is running ESLint version 9.12.0:

Image description

The issue arises because I use Bun to manage the packages in my project, but when running npm run lint -w myFolder, it uses npm (the Node.js package manager) instead of Bun. This causes a version mismatch, as npm installs or uses a different version of ESLint than the one managed by Bun.

Solution

Install the same version of ESLint as specified in package.json in Node.js using npm by running the following command:

npm i eslint@9.9.0 -D
Enter fullscreen mode Exit fullscreen mode

Check the installed version

npm ls eslint
Enter fullscreen mode Exit fullscreen mode

Check the output to see if the version is correct

Image description

Run the command below again to see the correct results

npm run lint -w myFolder
Enter fullscreen mode Exit fullscreen mode

Top comments (0)