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:
- Recommended:
packageManagerfield inpackage.json: Add"packageManager": "npm@10.2.0"to yourpackage.json. The Step will enable corepack, which automatically enforces this version whennpmis called. npm_versioninput: Set the Version of npm to use input to an exact version number (e.g.10.2.0). This takes priority over thepackageManagerfield and installs that specific version viacorepack prepare.
If neither is set, the Step runs npm as-is without changing the version.
Configuring the Step
- Add the Run npm command Step to your Workflow preceding any build Step.
- Set the Working directory.
- Set the command you want npm to execute, for example
installto runnpm installin the The npm command with arguments to run input. - Optionally pin the npm version via the
packageManagerfield inpackage.jsonor 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
- Getting started Ionic/Cordova apps
- NPM cache save and restore Steps
- About npm
- Corepack documentation

