How to use NVM to run different versions of Node.js

Node Version Manager or NVM is a tool for managing multiple versions of Node.js in one installation.

You can use NVM with any of our container types that have node installed to change or update the version. This may be useful, for example, where a container has a Long Term Release (LTS) version available, but you would like to use the latest.

Installing NVM is done in the build hook of your, which some additional calls to ensure that environment variables are set correctly.

    build: |
        unset NPM_CONFIG_PREFIX
        curl -o- | dash
        export NVM_DIR="$HOME/.nvm"
        [ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"
        nvm current
        nvm install 9.5.0
    deploy: |
        unset NPM_CONFIG_PREFIX
        nvm use 9.5.0

And in a .environment file in the root of your project:

# This is necessary for nvm to work.
# Disable npm update notifier; being a read only system it will probably annoy you.
# This loads nvm for general usage.
[ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"