Eslint cannot find module, hyphens vs slashes

Answered

In .eslintrc I have this

"extends": [
"standard",
"plugin:react/recommended",
"prettier",
"prettier/react",
"prettier/standard"
],

The first error I receive is:

Error: Cannot find module 'eslint-config-prettier/standard'

In node modules I have `node_modules/eslint-config-prettier-standard`

Note the difference between the slash and the hyphen in the rc file vs the directory.

If I remove the slash (/) in the .eslintrc and replace it with a hyphen ("prettier-standard") the issue goes away and the next issue in the queue is 

Error: Cannot find module 'eslint-config-prettier/standard'
Referenced from: [obfuscated for privacy]/node_modules/eslint-config-prettier-standard/end.js
Referenced from: [obfuscated for privacy]/node_modules/eslint-config-prettier-standard/index.js

This seems like a Linux vs. macOS issue possibly - I have to be careful with edits to these files since I'm working on a shared project and the config I'm getting from Git is mostly for Mac users, though the second error is inside the library itself, which is more perplexing. I've searched quite a bit to see if there is something I can change in my yarn or npm config that would've accounted for this, but I'm not finding anything. I've done the same for eslint configs - is there an option that can be passed to Intellij in ESLint "additional rules" or "extra options" that might allow the slashes vs hyphens to be interpreted correctly?

0
4 comments

Does ESLint work in the terminal when using similar settings? cd to project directory and try running eslint to it, like eslint --config path/to/config . What is a result?

0
Avatar
Permanently deleted user

Does this mean it's configured to look at global packages rather than local?

This is the output of that command:

Error: Cannot read config file: /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint-config-prettier-standard/eslint-file-base.js
Error: Cannot find module 'prettier-config-standard'
Require stack:
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint-config-prettier-standard/prettierrc.js
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint-config-prettier-standard/eslint-file-base.js
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint/lib/config/config-file.js
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint/lib/config.js
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint/lib/cli-engine.js
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint/lib/cli.js
- /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint/bin/eslint.js
Referenced from: /home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint-config-prettier-standard/index.js
Referenced from: /home/mick/Documents/[...]/.eslintrc
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Module.require (internal/modules/cjs/loader.js:848:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/mick/.nvm/versions/node/v12.15.0/lib/node_modules/eslint-config-prettier-standard/prettierrc.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:955:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
at Module.load (internal/modules/cjs/loader.js:811:32)
at Function.Module._load (internal/modules/cjs/loader.js:723:14)
at Module.require (internal/modules/cjs/loader.js:848:19)

 

0

As the issue is not related to IntelliJ IDEA, it is better to ask that on a profile forum, or on StackOverflow. 

A similar problem has been addressed on the project's Github: 

https://github.com/standard/eslint-config-standard/issues/84#issuecomment-315129706

 

0
Avatar
Permanently deleted user

Right, thank you for putting me down the correct path. It seems related to recent updates to ESLint and the way it handles global/local packages... Thank you again!

0

Please sign in to leave a comment.