NodeJS and Grunt
Moodle development tools require the installation and use of NodeJS, which is a JavaScript runtime environment available for most operating systems.
Moodle requires version 16.14 of NodeJS, which is otherwise known as lts/gallium
.
Use of NVM for installation of NodeJS is highly recommended over direct installation.
Node Version Manager
NVM is the Node Version Manager. Its purpose is to simplify the installation, and use different versions of NodeJS.
Moodle includes a .nvmrc
which nvm
can use to select the correct version of NodeJS.
To use the correct version of NodeJS for the current version of Moodle, you can use the nvm install
and nvm use
commands:
$ nvm install
Found '/Users/nicols/Sites/public_html/sm/.nvmrc' with version <lts/gallium>
v16.14.0 is already installed.
Now using node v16.14.0 (npm v8.3.1)
Grunt
As part of its build stack, Moodle uses the Grunt task runner.
Grunt is composed of a set of tasks, defined within the Moodle code repository in the Gruntfile.js
file, and a grunt CLI tool which must also be installed.
To install the grunt CLI tool you can install it globally using npm:
$ npm install -g grunt-cli
$ grunt stylelint
You can also use the npx
command to install it on demand:
$ npx grunt stylelint