This content originally appeared on DEV Community and was authored by Jen C.
When get the error by running
npm run lint -w myFolder
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
...
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
:
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
Check the installed version
npm ls eslint
Check the output to see if the version is correct
Run the command below again to see the correct results
npm run lint -w myFolder
This content originally appeared on DEV Community and was authored by Jen C.
Jen C. | Sciencx (2024-11-07T17:06:05+00:00) How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues. Retrieved from https://www.scien.cx/2024/11/07/how-to-fix-common-eslint-errors-troubleshooting-unknown-or-strange-issues/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.