Help Center/ CodeArts Build/ FAQs/ npm Builds/ How Do I Configure a Mirror Source in the .npmrc File?
Updated on 2025-10-15 GMT+08:00

How Do I Configure a Mirror Source in the .npmrc File?

Symptoms

The mirror source cannot be set via the build command.

Cause Analysis

For Node.js versions later than 18, the mirror source cannot be set via the build command.

Solution

Create an .npmrc file in the root directory of the code repository, and configure the mirror source in the file. For example, when using a CodeArts Repo repository, follow these steps:

  1. Access the CodeArts Repo homepage and find the code repository used by your project.
  2. Click the name of the code repository and, in the root directory, choose Create > Create File. Name the new file .npmrc.
  3. Add your mirror source configuration to the file. (You may refer to the following code sample.) After completing the configuration, click OK.
    disturl=https://repo.example.com/nodejs
    sass_binary_site=https://repo.example.com/node-sass/
    phantomjs_cdnurl=https://repo.example.com/phantomjs
    chromedriver_cdnurl=https://repo.example.com/chromedriver
    operadriver_cdnurl=https://repo.example.com/operadriver
    electron_mirror=https://repo.example.com/electron/
    python_mirror=https://repo.example.com/python
    Figure 1 Configuring the mirror source

    Note: If there is any conflict between commands shown on the product page and the settings in .npmrc, the .npmrc configuration takes precedence.