npm task
Azure Pipelines | TFS 2018 | TFS 2017 | TFS 2015
Use this task in a build or release pipeline to install and publish npm packages.
Note
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, service connections are called service endpoints, stages are called environments, and jobs are called phases.
Install npm packages
Demands
YAML snippet
# npm
# Install and publish npm packages, or run an npm command. Supports npmjs.com and authenticated registries like Package Management.
- task: Npm@1
inputs:
#command: 'install' # Options: install, publish, custom
#workingDir: # Optional
#verbose: # Optional
#customCommand: # Required when command == Custom
#customRegistry: 'useNpmrc' # Optional. Options: useNpmrc, useFeed
#customFeed: # Required when customRegistry == UseFeed
#customEndpoint: # Optional
#publishRegistry: 'useExternalRegistry' # Optional. Options: useExternalRegistry, useFeed
#publishFeed: # Required when publishRegistry == UseFeed
#publishPackageMetadata: true # Optional
#publishEndpoint: # Required when publishRegistry == UseExternalRegistry
Arguments
Argument | Description |
---|---|
Command |
npm command to run. Select install here.
|
Working folder with package.json | Path to the folder containing the target package.json and .npmrc files. Select the folder, not the file e.g. "/packages/mypackage". |
Custom registries and authentication | |
Registries to use |
Leave this section blank to use packages from npmjs directly. Otherwise, select one of these options:
Registries in my .npmrc:
|
Advanced | |
Verbose logging | Enables verbose logging. |
Control options |
Publish npm packages
Demands
Arguments
Argument | Description |
---|---|
Command |
npm command to run. Select publish here.
|
Working folder with package.json | Path to the folder containing the target package.json and .npmrc files. Select the folder, not the file e.g. "/packages/mypackage". |
Destination registry and authentication | |
Registry location |
|
Advanced | |
Verbose logging | Enables verbose logging. |
Control options |
Custom npm command
Demands
Arguments
Argument | Description |
---|---|
Command |
npm command to run. Select custom here.
|
Working folder with package.json | Path to the folder containing the target package.json and .npmrc files. Select the folder, not the file e.g. "/packages/mypackage". |
Command and arguments |
The custom command and arguments you wish to be executed.
If your arguments contain double quotes ("), escape them with a slash (\), and surround the escaped string with double quotes ("). Example: to run npm run myTask -- --users='{"foo":"bar"}' , provide this input: run myTask -- --users="{\"foo\":\"bar\"}" .
|
Custom registries and authentication | |
Registries to use |
Leave this section blank to use packages from npmjs directly. Otherwise, select one of these options:
Registries in my .npmrc:
|
Control options |
Examples
Build your Node.js app with gulp
Open source
This task is open source on GitHub. Feedback and contributions are welcome.
Q & A
Where can I learn npm commands and arguments?
Do I need an agent?
You need at least one agent to run your build or release. Get an agent for Linux, macOS, or Windows.
I can't select a default agent pool and I can't queue my build or release. How do I fix this?
See Agent pools.
I use TFS on-premises and I don't see some of these features. Why not?
Some of these features are available only on Azure Pipelines and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.
Feedback
We'd love to hear your thoughts. Choose the type you'd like to provide:
Our feedback system is built on GitHub Issues. Read more on our blog.
Loading feedback...