Partajați prin


Publish and restore npm packages from the command line

TFS 2018

Follow this quick tutorial to learn how to connect your npm client to your feed and publish your packages using the command line. If you don't have a feed yet, you can follow the steps in the quickstart to Create your own feed.

Project setup

  1. Navigate to your project,and then select Artifacts then select Connect to feed.

  2. Select npm from the left navigation panel, and then follow the instructions under Project setup to configure your .npmrc file and connect to your feed. If this is your first time using Azure Artifacts with npm on your machine, make sure you select Get the tools to download and install the prerequisites.

    Screenshot showing how to set up your project

Publish packages

  1. Open a command prompt window and navigate to the directory that contains your package.json. If you don't have a package.json file, run the following command:

    npm init 
    
  2. Run the following command in your project directory to publish your npm packages:

    npm publish
    

Note

If your organization is using a firewall or a proxy server, make sure you allow Azure Artifacts Domain URLs and IP addresses.

Restore packages

  1. Run the following command in your project directory to restore your npm packages:

    npm install