Skip to main content

npm CLI reference

ModularPipelines.Node provides strongly typed access to the npm CLI.

Executable prerequisite​

This package does not install the npm executable. Install it separately and ensure npm is available on PATH.

See the npm installation guide.

Install npm with a supported Node.js distribution.

Package installation​

dotnet add package ModularPipelines.Node

Resolve the service with context.Tools.Npm. Projects using C# 13 or another .NET language can use context.Tools.Get<ModularPipelines.Node.Services.INpm>() instead.

Module example​

using ModularPipelines;
using ModularPipelines.Node.Options;

public class RunCommandModule : Module<CommandResult>
{
protected override async Task<CommandResult> ExecuteAsync(
IModuleContext context,
CancellationToken cancellationToken)
{
return await context.Tools.Npm.Audit.ExecuteAsync(
new NpmAuditOptions()
{
AuditLevel = "high",
},
cancellationToken: cancellationToken);
}
}

Global options​

Global options are rendered after the selected subcommand.

CLI optionPropertyAvailabilityDescription
--caCaAll editionsTrusted certificate authority certificates in PEM format.
--cacheCacheAll editionsDirectory used for npm's cache.
--cafileCafileAll editionsFile containing trusted certificate authority certificates.
--colorColorAll editionsColor output policy: true, false or always.
--fetch-retriesFetchRetriesAll editionsNumber of retries for registry reads.
--fetch-retry-factorFetchRetryFactorAll editionsExponential factor used for retry delays.
--fetch-retry-maxtimeoutFetchRetryMaxtimeoutAll editionsMaximum retry delay in milliseconds.
--fetch-retry-mintimeoutFetchRetryMintimeoutAll editionsMinimum retry delay in milliseconds.
--fetch-timeoutFetchTimeoutAll editionsMaximum request duration in milliseconds.
--globalconfigGlobalconfigAll editionsRead global configuration from this file.
--headingHeadingAll editionsPrefix used for debugging log output.
--https-proxyHttpsProxyAll editionsProxy URL for HTTPS requests; may contain credentials.
--loglevelLoglevelAll editionsLog verbosity: silent, error, warn, notice, http, info, verbose or silly.
--logs-dirLogsDirAll editionsDirectory used for npm's log files.
--logs-maxLogsMaxAll editionsMaximum number of log files to retain; zero disables log files.
--noproxyNoproxyAll editionsHosts that bypass the proxy.
--offlineOfflineAll editionsUse the cache without network requests.
--prefer-offlinePreferOfflineAll editionsSkip cache staleness checks but fetch missing data.
--prefer-onlinePreferOnlineAll editionsCheck cached data for freshness immediately.
--prefixPrefixAll editionsRun non-global commands in this directory; also sets the global installation prefix.
--progressProgressAll editionsDisplay progress during time-intensive operations.
--proxyProxyAll editionsProxy URL for HTTP requests; may contain credentials.
--registryRegistryAll editionsBase URL of the package registry.
--strict-sslStrictSslAll editionsValidate TLS certificates for registry requests.
--timingTimingAll editionsWrite timing information for this invocation.
--unicodeUnicodeAll editionsUse Unicode characters instead of ASCII in output.
--userconfigUserconfigAll editionsRead user configuration from this file.

Commands​

CLI commandOptions record
npm access get statusNpmAccessGetStatusOptions
npm access grantNpmAccessGrantOptions
npm access list collaboratorsNpmAccessListCollaboratorsOptions
npm access list packagesNpmAccessListPackagesOptions
npm access revokeNpmAccessRevokeOptions
npm access setNpmAccessSetOptions
npm adduserNpmAdduserOptions
npm auditNpmAuditOptions
npm audit fixNpmAuditFixOptions
npm audit signaturesNpmAuditSignaturesOptions
npm bugsNpmBugsOptions
npm cache addNpmCacheAddOptions
npm cache cleanNpmCacheCleanOptions
npm cache lsNpmCacheLsOptions
npm cache npx infoNpmCacheNpxInfoOptions
npm cache npx lsNpmCacheNpxLsOptions
npm cache npx rmNpmCacheNpxRmOptions
npm cache verifyNpmCacheVerifyOptions
npm ciNpmCiOptions
npm completionNpmCompletionOptions
npm config deleteNpmConfigDeleteOptions
npm config editNpmConfigEditOptions
npm config fixNpmConfigFixOptions
npm config getNpmConfigGetOptions
npm config listNpmConfigListOptions
npm config setNpmConfigSetOptions
npm dedupeNpmDedupeOptions
npm deprecateNpmDeprecateOptions
npm diffNpmDiffOptions
npm dist-tag addNpmDistTagAddOptions
npm dist-tag lsNpmDistTagLsOptions
npm dist-tag rmNpmDistTagRmOptions
npm docsNpmDocsOptions
npm doctorNpmDoctorOptions
npm editNpmEditOptions
npm execNpmExecOptions
npm explainNpmExplainOptions
npm exploreNpmExploreOptions
npm find-dupesNpmFindDupesOptions
npm fundNpmFundOptions
npm getNpmGetOptions
npm helpNpmHelpOptions
npm help-searchNpmHelpSearchOptions
npm initNpmInitOptions
npm installNpmInstallOptions
npm install-ci-testNpmInstallCiTestOptions
npm install-testNpmInstallTestOptions
npm linkNpmLinkOptions
npm loginNpmLoginOptions
npm logoutNpmLogoutOptions
npm lsNpmLsOptions
npm org lsNpmOrgLsOptions
npm org rmNpmOrgRmOptions
npm org setNpmOrgSetOptions
npm outdatedNpmOutdatedOptions
npm owner addNpmOwnerAddOptions
npm owner lsNpmOwnerLsOptions
npm owner rmNpmOwnerRmOptions
npm packNpmPackOptions
npm pingNpmPingOptions
npm pkg deleteNpmPkgDeleteOptions
npm pkg fixNpmPkgFixOptions
npm pkg getNpmPkgGetOptions
npm pkg setNpmPkgSetOptions
npm prefixNpmPrefixOptions
npm profile disable-2faNpmProfileDisableNumber2faOptions
npm profile enable-2faNpmProfileEnableNumber2faOptions
npm profile getNpmProfileGetOptions
npm profile setNpmProfileSetOptions
npm pruneNpmPruneOptions
npm publishNpmPublishOptions
npm queryNpmQueryOptions
npm rebuildNpmRebuildOptions
npm repoNpmRepoOptions
npm restartNpmRestartOptions
npm rootNpmRootOptions
npm runNpmRunOptions
npm sbomNpmSbomOptions
npm searchNpmSearchOptions
npm setNpmSetOptions
npm shrinkwrapNpmShrinkwrapOptions
npm starNpmStarOptions
npm starsNpmStarsOptions
npm startNpmStartOptions
npm stopNpmStopOptions
npm team addNpmTeamAddOptions
npm team createNpmTeamCreateOptions
npm team destroyNpmTeamDestroyOptions
npm team lsNpmTeamLsOptions
npm team rmNpmTeamRmOptions
npm testNpmTestOptions
npm token createNpmTokenCreateOptions
npm token listNpmTokenListOptions
npm token revokeNpmTokenRevokeOptions
npm trustNpmTrustOptions
npm undeprecateNpmUndeprecateOptions
npm uninstallNpmUninstallOptions
npm unpublishNpmUnpublishOptions
npm unstarNpmUnstarOptions
npm updateNpmUpdateOptions
npm versionNpmVersionOptions
npm viewNpmViewOptions
npm whoamiNpmWhoamiOptions