Reputation: 749
I have the following directory structure:
/
├──.node-modules
├──server # server code
│ ├──...
├──shared # modules used by client and server
├──webapp # client code
│ ├──...
│ ├──eslintrc.js # client eslint config
├──eslintrc.js # project eslint config
└──webpack.config.js
I use Vue for client code and dbaeumer.vscode-eslint
extension for VSCode. On the .vue
files I keep getting errors on the import
statements.
Unable to resolve path to module
module
I've been messing with eslint.workingDirectories
settings to set this up, but had no success. Inside my client local eslint config I have the import/resolver defined:
module.exports = {
...
settings: {
'import/resolver': 'webpack',
},
}
Upvotes: 1
Views: 10010
Reputation: 749
It was a node
version issue. My distro only distributes the latest version of node
. I've done the following for the errors to correct themselves.
Set the version of node to 10.10.0
$ nvm install 10.10.0
$ nvm use 10.10.0
Inside the home/user/'Code - OSS'/User/settings.json
file, added the following field to the JSON
settings:
{
...
"eslint.runtime": "/home/user/.nvm/versions/node/v10.10.0/bin/node" // This should be the path to the node runtime set by nvm
}
After saving and restarting VSCode the errors were gone and ESLint is working correctly now.
NOTE: Check which version your system is using with nvm ls
command. The output should look something like this
$ nvm ls
v6.14.4
-> v10.10.0
v10.20.0
v12.16.2
default -> 10.10.0 (-> v10.10.0)
node -> stable (-> v12.16.2) (default)
stable -> 12.16 (-> v12.16.2) (default)
iojs -> N/A (default)
unstable -> N/A (default)
lts/* -> lts/erbium (-> v12.16.2)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.20.0
lts/erbium -> v12.16.2
Thank you for the help everyone. Sorry if the question did not give more relevant details as I did not have any clue on where the problem may lay, so I asked for assistance from a good friend who's experienced.
Upvotes: 3
Reputation: 51
Did you try to install these packages?
npm install eslint-plugin-import --save-dev
npm install eslint-plugin-node --save-dev
npm install eslint-plugin-promise --save-dev
npm install eslint-plugin-standard --save-dev
Upvotes: 0
Reputation: 538
I used this video while installing ESlint on my VS Code a while back.
Maybe it can be an issue with version, and you can check the best version that worked from here.
Upvotes: 0