New Feature to Node.js Performance Platform: Module Repository

Image for post
Image for post

By Yijun

In this blog, you learn about the Module Repository feature of Node.js Performance Platform, which is developed on top of cnpm. You also will learn how you can publish a private package using Module Repository.

Preface

Due to Internet restrictions in China, developers cannot install the official npm warehouse very quickly or easily. To mitigate this issue, Alibaba provides the complete image warehouse cnpm to allow developers in China to replace npm with cnpm. The source code of the cnpm image warehouse is open to the public. Many enterprises that need to publish and install private modules have started to use cnpm to build their own private image warehouses.

Module Repository

Node.js Performance Platform is also developed on top of cnpm. Node.js Performance Platform provides developers with a private warehouse free of charge, specifically the Module Repository. The purpose of this feature is to simplify the Node.js development environment, giving developers more time to focus more on the business aspects of development. This can all be done through the Module Repository and through also combining the underlying performance monitoring, upper-layer application frameworks together. (For these specific purposes, Egg.js is recommended.)

Compared with the private warehouses many enterprises build by using the open-source version of cnpm, the Module Repository has the following advantages:

  • Lower operations cost for enterprises: Traditionally, an enterprise needs to maintain at least one physical machine (ECS instance) and all the corresponding storage space if it builds a private warehouse that can meet its development scale, which can be a very costly undertaking. Module Repository eliminates the need to maintain this infrastructure.
  • A wider range of application scenarios: Private warehouses built by enterprises internally cannot allow them to share some private modules with their external partners. Module Respository, on the other hand, allows for such actions.
  • More accurate access control: Private warehouses built on top of cnpm do not allow for download/publish permission controls. However, Module Repository allows for fine-granularity authorization control over permissions, including controlling permissions by user.

In addition to covering all features of private cnpm warehouses, Module Repository in Node.js Performance Platform also supports the separation of multiple users and fine-grained access controls to meet several different enterprise development scenarios.

Currently, Module Repository is available free of charge, allowing you to take advantage of all of these advanced features.

Trial

This tutorial shows how you can publish a private package using Module Repository in Node.js Performance Platform.

To do it, follow the steps given here:

Create a Registry

When you access the Module Repository homepage for the first time, you first need to create a Registry, which will serve as your private warehouse. Click Create a Registry in the upper-right corner to create a private Module Repository.

Log on to the Registry

After the Registry is created, you can see the address of the private warehouse:

Image for post
Image for post

Use the npm/cnpm command shown in the figure to direct the npm/cnpm client warehouse to this private module warehouse, and then perform the logon operation. The account information required for the npm/cnpm client login command can be found in My Information:

Image for post
Image for post

Create a Scope

Next, click Create a Scope in the upper-right section of the Module Repository homepage to create a Scope under this private warehouse by business, department, function, or any other factor that you want:

Image for post
Image for post

After the Scope is created, publish a private module with the corresponding package name into this Scope. For example, a Scope named @cloud is created in this example. You can run the npm publish command to publish the package named @cloud/quickstart to this Scope.

More Features

The preceding section shows a simple example in which only one person uses the Module Repository. However, in actual development scenarios, it is inevitable that many people need to develop and maintain private modules in a collaborative manner. Module Repository in Node.js Performance Platform also provides complete support for collaborative development. For more information about the collaborative development with Module Repository, see Module Repository User Guide.

Original Source

Written by

Follow me to keep abreast with the latest technology news, industry insights, and developer trends.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store