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.
- Open Settings and go to
Languages and Frameworks | Node.js
. - 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
- Click on OK to save
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:
- Install ESLint globally using
npm i --g eslint
or a package manager of your choice. - Open Settings and go to
Languages and Frameworks | JavaScript | Code Quality Tools | ESLint
. - 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:
npm list -g
- View your global package versionnpm install --g [email protected] --save-exact
- Change your package version to an exact version, here 8.22.0rm -rf node_modules/