How to find what node version a project supports

coiso picture coiso · Mar 15, 2017 · Viewed 20k times · Source

Is there a way besides trial and error to detect what node version I should use on a repository ?

With the fast rise of web frameworks it's becoming a common need to go back to projects from 6, 12 or 24+ months ago. I've been doing this a lot in the last weeks and my process for detecting the correct node version has become:

git clone [REPO]
npm i
[build]
### if error
rm -r node_modules
nvm use 4, 5 or 6
npm i
[build]

I can't help but feel that there's something very basic I'm missing here. Thanks for any wisdom you can share with me!

Answer

Varedis picture Varedis · Mar 15, 2017

If these are your own repos, then you can store the Node version in package json for your reference.

"version": "1.0.0",
"engines": {
    "node": "7.x"
},
"description": "..."

This won't automatically setup the correct version, but it would provide you with somewhere to look.