To specify which version of Node the app should be using, use the engines property on package.json, like so (in this case sticking to version 5):
{
"name": "my-app",
...
"engines": {
"node": ">=5.0.0 <6.0.0"
}
}
This one has the same effect:
{
"name": "my-app",
...
"engines": {
"node": "^5.0.0"
}
}
Docs:
engines is meant to set node version for dependencies. If you want to reinforce the use of the node version and throw an error, you can use a package like:
https://www.npmjs.com/package/engine-check
npm install --save engine-check or yarn add engine-check
When dealing with node, the need to change node versions locally has become common place.
Save yourself a lot of headache and manage
nodethroughnvm(node version manager) only, if you can help it.
All other alternatives (installing node directly with curl, indirectly through binary installers or homebrew) are simply not as flexible.
Docs: