Skip to content

Instantly share code, notes, and snippets.

@hmlimkokhoe
Last active October 20, 2022 12:39
Show Gist options
  • Save hmlimkokhoe/7294d809097d610f0332e943779e275a to your computer and use it in GitHub Desktop.
Save hmlimkokhoe/7294d809097d610f0332e943779e275a to your computer and use it in GitHub Desktop.
Troubleshoot tips for IntelliJ

Cannot find module error on WSL

If you get something like typescript: Cannot find module 'react' while working on IntelliJ with WSL, there's a chance you haven't set your Node.js interpreter.

  1. Open Settings and go to Languages and Frameworks | Node.js.
  2. Select Node interpreter. Then, set the path of your Node.js installation to something like below:
\\wsl$\Ubuntu\home\my_name\.nvm\versions\node\v14.19.0\bin\node
  1. Click on OK to save

Automatic ESLint configuration not working

This error occurs, despite having ESLint locally installed in your project and including an .eslintrc file. It would show you something like "ESLint: Please specify path to 'eslint' package" as error message.

To fix this, you should set your configuration manually by locating your globally installed ESLint module in IntelliJ:

  1. Install ESLint globally using npm i --g eslint or a package manager of your choice.
  2. Open Settings and go to Languages and Frameworks | JavaScript | Code Quality Tools | ESLint.
  3. Select "Manual ESLint configuration". Then, set "ESLint package" with the path of your globally installed ESLint module. Below, is an example path in WSL and NVM:
\\wsl$\Ubuntu\home\my_name\.nvm\versions\node\v14.19.0\pnpm-global\5\node_modules\.pnpm\[email protected]\node_modules\eslint

If the above doesn't fix your issue, a version mismatch is likely between your globally installed ESLint package and your project's ESLint package. To solve it, try to update your global ESLint package to the same version as your project's package:

  1. npm list -g - View your global package version
  2. npm install --g [email protected] --save-exact - Change your package version to an exact version, here 8.22.0
  3. rm -rf node_modules/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment