Search code examples
ddev

Install a specific node version with ddev and keep in container


What is the recommended way to do the follwing:

  • install a specific version of node in a ddev container
  • so it persists (after ddev stop/start)
  • and every user that downloads and builds the container gets the right node version?

The idea behind it is to "nail" the node version for compatibility (in our case, with older versions of Foundation for Sites framework)


Solution

  • [Updated 2024-10-15]

    You may either:

    • use ddev nvm to change node versions on the fly

    • (preferred) use nodejs_version in your DDEV config YAML, specifying any available major, minor, or patch versions of nodejs. E.g., nodejs_version: 20 or nodejs_version: 22.3 or nodejs_version: 21.7.3