Jaa


npm task

TFS 2017 | TFS 2015

Use this task to install and publish npm packages.

Note

The npm Authenticate task is the recommended way to authenticate with Azure Artifacts. This task no longer takes new features and only critical bugs are addressed.

Note

In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.

Install npm packages

Demands

npm

Arguments

Argument Description
command
Command
(Required) npm command to run. Default: install. Options: install, publish, custom, ci.
workingDir
Working folder that contains package.json
Path to the folder containing the target package.json and .npmrc files. Select the folder, not the file e.g. "/packages/mypackage".
advanced
Verbose logging
Select to print more information to the console on run
customRegistries
Registries to use
You can either commit a .npmrc file to your source code repository and set its path or select a registry from Azure Artifacts.
useNpmrc
  • Select this option to use feeds specified in a .npmrc file you've checked into source control. If no .npmrc file is present, the task will default to using packages directly from npmjs.
  • Credentials for registries outside this organization/collection can be used to inject credentials you've provided as an npm service connection into your .npmrc as the build runs.
    useFeed
  • Select this option to use one Azure Artifacts feed in the same organization/collection as the build.
  • Publish npm packages

    Demands

    npm

    Arguments

    Argument Description
    command
    Command
    (Required) npm command to run. Select publish here.
    workingDir
    Working folder that contains package.json
    Path to the folder containing the target package.json and .npmrc files. Select the folder, not the file e.g. "/packages/mypackage".
    advanced
    Verbose logging
    Select to print more information to the console on run
    customRegistries
    Registries to use
    You can either commit a .npmrc file to your source code repository and set its path or select a registry from Azure Artifacts.
    useNpmrc
  • Select this option to use feeds specified in a .npmrc file you've checked into source control. If no .npmrc file is present, the task will default to using packages directly from npmjs.
  • Credentials for registries outside this organization/collection can be used to inject credentials you've provided as an npm service connection into your .npmrc as the build runs.
    useFeed
  • Select this option to use one Azure Artifacts feed in the same organization/collection as the build.
  • Custom npm command

    Demands

    npm

    Arguments

    Argument Description
    command
    Command
    (Required) npm command to run. Select custom here.
    workingDir
    Working folder that contains package.json
    Path to the folder containing the target package.json and .npmrc files. Select the folder, not the file e.g. "/packages/mypackage".
    customCommand
    Command and arguments
    (Required) Custom command to run, e.g. "dist-tag ls mypackage".
    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"}".
    customRegistries
    Registries to use
    You can either commit a .npmrc file to your source code repository and set its path or select a registry from Azure Artifacts.
    useNpmrc
  • Select this option to use feeds specified in a .npmrc file you've checked into source control. If no .npmrc file is present, the task will default to using packages directly from npmjs.
  • Credentials for registries outside this organization/collection can be used to inject credentials you've provided as an npm service connection into your .npmrc as the build runs.
    useFeed
  • Select this option to use one Azure Artifacts feed in the same organization/collection as the build.
  • Examples

    Build: gulp

    Build your Node.js app with gulp

    Open source

    This task is open source on GitHub. Feedback and contributions are welcome.

    FAQ

    Where can I learn npm commands and arguments?

    npm docs

    Do I need an agent?

    You need at least one agent to run your build or release.

    I'm having problems. How can I troubleshoot them?

    See Troubleshoot Build and Release.

    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.

    My NuGet push task is failing with the following error: "Error: unable to get local issuer certificate". How can I fix this?

    This can be fixed by adding a trusted root certificate. You can either add the NODE_EXTRA_CA_CERTS=file environment variable to your build agent, or you can add the NODE.EXTRA.CA.CERTS=file task variable in your pipeline. See Node.js documentation for more details about this variable. See Set variables in a pipeline for instructions on setting a variable in your pipeline.

    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.

    My Pipeline needs to access a feed in a different project

    If the pipeline is running in a different project than the project hosting the feed, you must set up the other project to grant read/write access to the build service. See Package permissions in Azure Pipelines for more details.