Jake Wilson
Jake Wilson

Reputation: 91193

Node Version Manager - I have to specify version on each boot?

On my dev server (CentOS), I installed nvm (Node Version Manager) and use that to install various node versions. nvm is installed for the root user only.

I noticed that after I restart the server, for root, # node -v gives me

bash: node: command not found

Of course I can simply say # nvm use v0.12.5 but then after another reboot, it doesn't stay. I have to re-specify it again.

Is this normal? Why is this? Is there a way to specify a default so I don't have to do this each time a reboot happens?

Upvotes: 1

Views: 552

Answers (1)

AL the X
AL the X

Reputation: 1051

There's an oft-overlooked paragraph at the top of the Usage section of the README (relevant emphasis mine):

You can create an .nvmrc file containing version number in the project root directory (or any parent directory). nvm use, nvm install, nvm exec, nvm run, and nvm which will all respect an .nvmrc file when a version is not supplied.

Using this method, you should be able to create a .nvmrc file in the home directory for root that would set the desired node version on at least interactive shells. Note that attempting to use nvm from non-interactive shells would be tricky, as it requires you to source .nvm/nvm.sh...

Additionally, you can register an alias named default for a specific version with nvm alias default <version>.

Upvotes: 3

Related Questions