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
Top comments (0)