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:
- Access the CodeArts Repo homepage and find the code repository used by your project.
- Click the name of the code repository and, in the root directory, choose Create > Create File. Name the new file .npmrc.
- 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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot