Operating system: Linux Mint based on Ubuntu Bionic (old version backported with new libs, unable to upgrade atm)
SonarLint plugin version: latest
IntelliJ version: latest
Programming language you’re coding in: PHP, Kotlin, Python, Yaml, json
Is connected mode used: no
And a thorough description of the problem / question:
The situation: I can’t run Node.js version older than 16.x.x due to old linux glibc version.
After upgrading SonarLint now I am getting the following msg:
SonarLint requires Node.js runtime version 18.17.0 or later to analyze YAML code. Current version is 16.14.0. Please configure the Node.js path in the SonarLint settings.
I have the following “tricks” to use newer nodejs versions in my workflow:
Created an alias ‘noded’ with the following line in my .bashrc: alias noded=‘docker run --rm --interactive --tty --name node -v $PWD:/home/node/app -w /home/node/app node:lts-alpine node’
Created a bash script in my /home/user/.local/bin/noded.sh with the content:
#!/bin/sh
docker run --rm --interactive --tty --name node -v $PWD:/home/node/app -w /home/node/app node:lts-alpine node “$@”
So, if I run noded --version or /bin/bash noded.sh --version I get the following:
v20.18.0
The issue is that I add ‘noded’ or ’ /bin/bash noded.sh’ or ‘noded.sh’ in the SonarLint Node.js setting path and I get ‘N/A’ for version (not detected) and code scanning is not working. No idea how nodejs is ran in the background, but I would like to run nodejs from docker containers for SonarLint.
We currently do not support this method of providing Node.js. I have created this improvement ticket on our side, but I cannot tell you when it will be tackled. There are many custom methods of providing Node.js, and it is difficult to manage all of them.
Knowing why you are leveraging containers to provide Node.js would be interesting. Could you please elaborate a bit more on the reasoning?
I have to support a range of legacy and newer nodejs applications which run on quite different nodejs versions and I manage this with an interactive nodejs version manager: n - npm
I’ve had no issues thus far just switching “n xx.xx” and I have the right version for the day.
But, (and this is my personal problem) I am also using an older Linux version on the work laptop which supports nodejs versions up to a point (v16.x) because of an older glibc libraries and nodejs 18.x is compiled with a newer version etc.
Thus I’ve started using nodejs with self-removable containers as it is easy to just alias them and go. And yes, all this is fixable with me upgrading the Linux distribution to a new one but that would involve a lot of headaches and I’ve always postponed that (because of the docker trick).
The reason I’ve wrote this ticket also is that in my JetBrains PHP/Kotlin etc workflows I am always using ephemeral docker containers to run unit tests, integration tests… dev/test containers, composer etc. and that works seamlessly inside the IDE. And the only thing that is not that “docker friendly” was the SonarLint execution. So everything is isolated from the host system but the nodejs required for some of the SonarLint scans. Making my host system agnostic to any versions either Java, PHP, Python, Kotlin, nodejs is kind of a requirement and a priority for me, because it is easy to switch contexts multiple times a day and I just need… docker on the machine and don’t need to get out of the IDE.
Hello, thank you for the explanations. Running Node.js from a remote environment is not on our roadmap at the moment but we’ll keep a record of this and continue to look out for similar requests. We would like to improve our support for remote environments and we’ll update this thread as soon as we tackle this.
Best regards,
Farah