npm_project_dependencies

npm_project_dependencies installs what a Node.js application's package-lock.json lists into the application's node_modules, with npm ci, as the application's account. The task names the directory on the node that holds package.json and the lock file, usually a release directory or a checkout. Command-line tools for the whole node are npm_global_package; an application that uses Yarn is yarn_project_dependencies.

The five lock file modules work the same way: the lock file is never rewritten, and a record in the lock file directory makes a rerun unchanged. That is in install what an application's lock file lists and in the design's what the lock file modules share. The rules of every language and tool installer, such as run_as_user_account, npm_program_path, and env, are in what the installers share.

Inputs

  • lock_file_dir (string; required): the directory on the node that holds package.json and the lock file, usually a release directory or a checkout
  • run_as_user_account (string; required): the application's account, which runs npm: npm runs code from the packages it installs
  • include_development_dependencies (boolean; required): false omits the packages listed under devDependencies in package.json. true installs development dependencies, which a build step on the node often needs.
  • npm_program_path (string; default found on the standard path): a written value must be absolute; the npm program to run when it is not npm on the standard path; its directory comes first in PATH, so npm finds the node beside it
  • env (mapping; optional): environment variables for npm, such as NPM_CONFIG_REGISTRY or a token for a private registry; values may be secrets

Outputs

The node task's result holds these fields. A later node task reads them as .node_tasks.<id>.<field>, where <id> is the node task's id.

  • status
  • change
  • value

What a dryrun reports

Compares the record and reports unchanged or would change with the reason; a lock file directory that does not exist yet, or a lock file or manifest that an earlier node task would change, is not checked.

Retries and time limits

Bounded automatic retries by default; retry: false turns them off.

The node task takes the time limits time_limit and time_limit_per_try; without them, the project's node_task_defaults apply. mmx describe-module task describes the settings every node task accepts.

Examples

Install a release's packages without development dependencies

- npm_project_dependencies:
    lock_file_dir: /srv/myapp/releases/v1.4.2
    run_as_user_account: myapp
    include_development_dependencies: false

include_development_dependencies is required. false leaves out the packages that package.json lists under devDependencies. true installs the devDependencies packages, which a build step on the node often needs. On the node, MMX runs npm ci in /srv/myapp/releases/v1.4.2 as the account myapp. npm ci deletes node_modules and installs exactly what package-lock.json lists. After a successful installation, MMX writes the record .mmx-npm-project-dependencies in the same directory; the next run is unchanged while the record matches and node_modules exists.

How it works

npm ci reads package-lock.json, or npm-shrinkwrap.json, and fails when the lock file is missing or does not fit package.json.

Tested on

Distributions: Debian 12 and 13, Ubuntu 24.04 and 26.04, Rocky Linux 9, AlmaLinux 10.

The suite language_installers.py runs on Debian 12 and 13, Ubuntu 24.04 and 26.04, Rocky Linux 9, and AlmaLinux 10, with Node.js 22 from nodejs.org unpacked under /opt, and installs against a lock file that the suite makes on the node, as a repository would carry it.

Why it works this way

  • A changed manifest reaches the installer's lock-file check. The shared installation record prevents an old successful installation from hiding a manifest change.
  • A written program path is absolute. Leaving the path out uses the installer's normal program selection, as the shared inputs explain.

This page is docs/reference/modules/npm_project_dependencies.md in the MMX repository.