Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enforcing node version on eslint server

I have a work project where I need to enforce an older version (10.24.1) of nodejs on eslint.

I'm managing my node version via nvm. Specifically, I've set my default version of nodejs to said 10.24.1 via

$ nvm alias default 10

enter image description here

This also checks out with running version and set eslint env version.

$ node -v
$ npx eslint --env-info

enter image description here

However, locally my ESLint seems to crash when viewing files in visual-studio-code.

enter image description here

I also tried specifying in local configuration in package.json:

"engines": {
  "node": ">=10.24.1"
}

This however seems to take no effect. So I'm not really sure what else I should do.

Is there any idea on how to enforce the eslint server to run on my specified node version instead of the v14.6.0?

like image 598
Samuel Hulla Avatar asked Aug 27 '26 14:08

Samuel Hulla


2 Answers

For users of VS Code add the following setting to your settings.json:

"eslint.runtime": "node"
like image 104
Marc Avatar answered Aug 30 '26 05:08

Marc


The only thing you need to do is use the setting eslint.runtime to specify the Node version you want the ESLint server to run on. There is no need to set the nvmrc nor to reinstall the package.

// settings.json
{
  "eslint.runtime": "/Users/user/.nvm/versions/node/v16.17.1/bin/node"
}

If you don't know where your node binary file is, you can use where node to find out if you are using a Unix-like terminal.

After saving the settings, an important thing is to restart your VSCode (it might not be enough if you only restart the ESLint server). You should see it run on a different version after that in the VSCode.

choose node version in ESLint server

like image 39
PJCHENder Avatar answered Aug 30 '26 05:08

PJCHENder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!