We work many projects at the same time and each project requires a specific node version to work.
When we switch from one project to another, we must switch node version. (we use n to switch)
Sometimes, node_modules
is compiled with a node version different than the one we are using to serve the project, and things tends to go bad.
We force the versions via building scripts and making use of the engines
field in package json when possible. When there are doubts, we remove that folder, but reinstall modules can be time compsuming in some projects.
I wonder if there is any reliable way to check the node version that performed the npm install
in a project with an existing node_modules
folder (assuming it was installed using a vanilla ‘npm install’)
I know that I can run a script that writes down the node version when install using package.json
, but I’m asking for a quick way to check the node version used to build already built projects.
I know that we can check package.json engines field, but that is not reliable.
Some articles say that in the package-lock.json
file may exist a node
property under the lockfileVersion
section. But this property might not be present in all cases, so is not reliable.