Hi,
I've been encountering a strange error when using eslint and I think (not 100% sure) that the issue might come from nodeenv.
I originally encountered the problem while using pre-commit (which uses nodeenv internally) but I was able to trim down the setup to a single file:
- Create a new virtual environment:
nodeenv env
- Activate it:
. env/bin/activate
- Install
eslint and globals (globally): npm install -g eslint globals
- Create a config file for eslint:
echo 'import globals from "globals"; export default [{languageOptions: { globals: globals.browser }}];' > eslint.config.mjs
- Run eslint:
eslint .
On my computer, this results in a crash with the following error:
Oops! Something went wrong! :(
ESLint: 9.2.0
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'globals' imported from /path/to/project/eslint.config.mjs
Did you mean to import "globals/index.js"?
at packageResolve (node:internal/modules/esm/resolve:845:9)
at moduleResolve (node:internal/modules/esm/resolve:918:18)
at defaultResolve (node:internal/modules/esm/resolve:1148:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:541:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
at ModuleJob._link (node:internal/modules/esm/module_job:126:49)
As a workaround, I can make the error go away by installing globals locally: npm install globals (with the virtual environment still active). After that running eslint . doesn't crash anymore.
Is there something that nodeenv is not handling correctly here, or is the issue somewhere further down the line?
Thanks! ✨
Hi,
I've been encountering a strange error when using
eslintand I think (not 100% sure) that the issue might come from nodeenv.I originally encountered the problem while using pre-commit (which uses nodeenv internally) but I was able to trim down the setup to a single file:
nodeenv env. env/bin/activateeslintandglobals(globally):npm install -g eslint globalsecho 'import globals from "globals"; export default [{languageOptions: { globals: globals.browser }}];' > eslint.config.mjseslint .On my computer, this results in a crash with the following error:
As a workaround, I can make the error go away by installing
globalslocally:npm install globals(with the virtual environment still active). After that runningeslint .doesn't crash anymore.Is there something that
nodeenvis not handling correctly here, or is the issue somewhere further down the line?Thanks! ✨