icon

Run npm command

The Step runs npm with the command and arguments you provide, for example, to install missing packages or run a package's test.

You can install missing JS dependencies with this Step if you insert it before any build step and provide the install command. You can also test certain packages with the test command. You can do both in one Workflow, however, this requires one Run npm command Step for installation followed by another Run npm command Step for testing purposes.

npm version pinning

The Step uses corepack to manage the npm version. There are two ways to pin the version:

  1. Recommended: packageManager field in package.json: Add "packageManager": "[email protected]" to your package.json. The Step will enable corepack, which automatically enforces this version when npm is called.
  2. npm_version input: Set the Version of npm to use input to an exact version number (e.g. 10.2.0). This takes priority over the packageManager field and installs that specific version via corepack prepare.

If neither is set, the Step runs npm as-is without changing the version.

Configuring the Step

  1. Add the Run npm command Step to your Workflow preceding any build Step.
  2. Set the Working directory.
  3. Set the command you want npm to execute, for example install to run npm install in the The npm command with arguments to run input.
  4. Optionally pin the npm version via the packageManager field in package.json or the Version of npm to use input.

Troubleshooting

Make sure you insert the Step before any build Step so that every dependency is downloaded a build Step starts running.

Useful links

Similar steps

Runs gulp with the given command and args.

Runs tslint with the given args.

Runs bower with the given command and args.

The Step runs Revopush cli with the command and arguments you provide, for example, to release release-react bundle .