Alternative Node.js install

Last updated 31st March 2021

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.

        # Update these for your desired NVM and Node versions.
        NVM_VERSION: v0.36.0
        NODE_VERSION: v14.13.1

    build: |
        unset NPM_CONFIG_PREFIX
        export NVM_DIR="$PLATFORM_APP_DIR/.nvm"
        # will automatically install NodeJS based on the presence of $NODE_VERSION
        curl -f -o-$NVM_VERSION/ | bash
        [ -s "$NVM_DIR/" ] && \. "$NVM_DIR/"

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/"

Did you find this guide useful?

Please feel free to give any suggestions in order to improve this documentation.

Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.

Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.

Thank you. Your feedback has been received.

These guides might also interest you...

OVHcloud Community

Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.

Discuss with the OVHcloud community

In accordance with the 2006/112/CE Directive, modified on 01/01/2015, prices incl. VAT may vary according to the customer's country of residence
(by default, the prices displayed are inclusive of the UK VAT in force).