Skip to main content

NodeJS

New LTS NodeJS versions are released every 12 months and supported for three years. Moodle tries to ensure a compromise between support and churn by ensuring that the version of NodeJS in use is supported at all times.

Policy statement

NodeJS

Since 3.1
  1. This policy will be applied to all supported branches, including stable and security-only releases.
  2. This policy does not require that any tool be updated, unless strictly needed by nodejs/npm or its own dependencies/changes
  3. It won't include npm audit changes either. Those are handled separately.
  4. Normally, only changes to .nvmrc and package.json will happen.
  5. Changes to project dependencies should be handled in a separate issue.

Project Dependencies

Since 5.0
  1. To avoid impact to the community, dependency updates which impact built output should be kept to a minimum.
  2. Dependency updates should be backported to the first Major release in a Series, for example Moodle 5.0.

Upgrade guidelines

NodeJS

To update the NodeJS version required, the following approach is typically recommended:

  1. Update the .nvmrc file to reflect the lts/[name] of the new LTS version

  2. Update the package.json to set the engines for the new restiction in the format: >= [new version] < [next version], for example:

    "engines": {
    "node": ">=20.11.0 <21"
    }
  3. Install the new NodeJS version:

    nvm install && nvm use
  4. Update the NodeJS dependencies with the new version of NodeJS:

    rm -rf node_modules
    npm install
  5. Verify the update:

    npx grunt
    npx grunt jsdoc

In most situations there will be no issues here and changes can be committed and backported to all stable and security-supported branches.

Troubleshooting

Where a project dependency is no longer supported due to the new version of NodeJS, it may be necessary to upgrade the dependency.

Project dependencies

The following tooling may be useful for the purposes of updating the project dependencies:

  • npm outdated
  • npm audit