1

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

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

$ nvm alias default 10

enter image description here

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

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

enter image description here

However, locally my ESLint seems to crash when viewing files in .

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 server to run on my specified node version instead of the v14.6.0?

Samuel Hulla
  • 6,617
  • 7
  • 36
  • 70
  • 1
    i think this covers your case? https://stackoverflow.com/questions/44700432/visual-studio-code-to-use-node-version-specified-by-nvm/48710384 – G-Force Sep 14 '21 at 15:18
  • Speficially the default alias woked for me: https://stackoverflow.com/a/44707192/5512705 – Samuel Hulla Sep 20 '21 at 09:11

3 Answers3

2

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

"eslint.runtime": "node"
Marc
  • 13,011
  • 11
  • 78
  • 98
1

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

PJCHENder
  • 5,570
  • 3
  • 18
  • 35
0

Add .nvmrc and .node-version files to your project directory

.nvmrc file content:

10.24.1

.node-version file content:

10.24.1

And after,

npm i -g @typescript-eslint should fix your issue.

Ghouse Mohamed
  • 387
  • 4
  • 10