In your role or node settings you can specify default attributes for any cookbook you use. Cookbook nodejs
allows you to set NodeJS version with the attribute version
(check its attributes/default.rb
file). But this attribute is taken into account only when NodeJS is installed from precompiled binaries or sources. So you need to specify install_method
as well (default is package
, i.e. installation via system package manager).
One more thing: you need to manually specify binary package checksum, which you can find in every release folder here: https://nodejs.org/download/release/
So, to install the latest version from official binaries use the following settings in role or node:
"nodejs": {
"install_method": "binary",
"binary": {
"checksum": "75b029b30d4a4147d67cf75bf6e034291fb5919c6935ec23f8365cee2d463f12"
},
"version": "5.3.0"
}