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

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 […


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:

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

Check the installed version

npm ls eslint

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


This content originally appeared on DEV Community and was authored by Jen C.


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues." Jen C. | Sciencx - Thursday November 7, 2024, https://www.scien.cx/2024/11/07/how-to-fix-common-eslint-errors-troubleshooting-unknown-or-strange-issues/
HARVARD
Jen C. | Sciencx Thursday November 7, 2024 » How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues., viewed ,<https://www.scien.cx/2024/11/07/how-to-fix-common-eslint-errors-troubleshooting-unknown-or-strange-issues/>
VANCOUVER
Jen C. | Sciencx - » How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/11/07/how-to-fix-common-eslint-errors-troubleshooting-unknown-or-strange-issues/
CHICAGO
" » How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues." Jen C. | Sciencx - Accessed . https://www.scien.cx/2024/11/07/how-to-fix-common-eslint-errors-troubleshooting-unknown-or-strange-issues/
IEEE
" » How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues." Jen C. | Sciencx [Online]. Available: https://www.scien.cx/2024/11/07/how-to-fix-common-eslint-errors-troubleshooting-unknown-or-strange-issues/. [Accessed: ]
rf:citation
» How to Fix Common ESLint Errors: Troubleshooting Unknown or Strange Issues | Jen C. | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.