Raised: $0
0% of monthly goal Help us cross the finish line!
Goal: $12,000
Raised: $0 Goal: $12,000
0% of monthly goal Help us cross the finish line!
Sponsor DDEV

add-on registry tests last commit release

DDEV NVM

Note

Since DDEV v1.25.0+, nvm is no longer included by default. The reasons are: Running ddev nvm install can make it unclear how to return to the version defined by nodejs_version. To switch back:

ddev nvm alias default system

And ddev nvm use doesn’t behave like the interactive nvm use, because nvm is a shell function rather than a standalone executable and cannot modify the shell environment inside DDEV. — For most projects, nodejs_version offers a more predictable workflow:

ddev config --nodejs-version=20

It also supports .nvmrc with:

ddev config --nodejs-version=auto

However, if you need nvm for managing multiple Node.js versions, this add-on provides that functionality.

Overview

This add-on integrates NVM into your DDEV project.

Installation

ddev add-on get ddev/ddev-nvm
ddev restart

After installation, make sure to commit the .ddev directory to version control.

Uninstallation

ddev add-on remove nvm
ddev restart
# Optionally remove cached nvm data
ddev exec 'rm -rf /mnt/ddev-global-cache/nvm_dir/$HOSTNAME'

After uninstallation, make sure to commit the .ddev directory to version control.

Usage

Tip

You can use NVM inside DDEV hooks:

# .ddev/config.yaml
hooks:
post-start:
- exec: "nvm install 18 && nvm alias default 18"

List installed Node.js versions:

ddev nvm ls

List Node.js versions available for installation:

ddev nvm ls-remote

Install a Node.js version and make it the default:

ddev nvm install 20
ddev nvm alias default 20

Warning

Don’t use ddev nvm use <version> as it won’t work as expected due to nvm being a shell function. Instead, use ddev nvm alias default <version> to set the default version.

Check the active Node.js version:

ddev nvm current
ddev exec node --version

Install latest npm version:

ddev nvm install-latest-npm
ddev npm --version

Switch between installed versions:

ddev nvm install 20
ddev nvm install 18
ddev nvm alias default 20
ddev nvm alias default 18

To stop using Node.js installed via NVM:

ddev nvm alias default system

Credits

Contributed and maintained by the DDEV team