It seems that npm does a good job at managing the dependencies of modules for a given project, with declarative dependency management (in the package.json file).
I would like to go one step further, and declaratively control which version of nodejs and npm from source control (i.e. specifying these versions in some file that is in the project' git repo, just like package.json)
On a freshly deployed machine, I would like to have only these steps :
1) clone a git repo of the nodejs project 2) install or update the versions of npm and nodejs 3) npm install
I woud then use this to have a single step deploy/update probably a script that does (2) and (3) and that feeds from a config file that is source controlled.
I'd be perfectly satisfied with a solution that only works on linux, or even for a given flavor of linux
Take a look at what Nodejitsu does with their Package.json. In particular you will see the following lines:
"engines": {
"node": "v0.8.x"
}
Then take a look at the Node Version Manager available here. There's a reasonable write-up on basic usage here.
Given that your deploys should all have a package.json this seems like a pretty straightforward method to achieve what you're looking for. Should be a limited amount of "glue" code and it's clearly possible as Nodejitsu is doing it.