Setup NPM package registry in the workspace

Requirements

We are working with Angular, for this reason we have some requirements to use our package.

  1. We need to install node from their website. You need to check the node version that is 16.15.0 or higher and npm version 8.10.0 or higher. Both versions are the recomended versions but probably the workspace works fine with the latest versions.

  2. If you want to work with our repository, you should install git to have access to our code.

  3. There is many editor to work with Angular, but in our experience we recommend using Visual Studio Code, since it is easy to install and use, apart from providing many plug-ins to streamline the development process.

Package Distribution

Each project in the Front-end generates a package. A package is the way to distribute our code. Node uses a package manager known as npm. You can use npm to install, update, or remove a package in a project.

WebMAP packages are published in two repositories, the first one is an internal NPM server that is currently deployed at http://ais-build-w7:81/npm/Frontend/ to provide packages to internal WebMAP developers and allow the installation of alpha npm packages as well as release packages. The internal server is only accessible using the company VPN.

The second one is the publuic NPM server that is deployed in an external sever accessible from web at https://packages.mobilize.net/npm/mobilizenet-npm/ it provides release packages to our clients and sales team, the repository only allows installation of release packages. The public server is accessible by anyone with a WebMAP license.

Finally but no least important there is a global and public server for the npm packages provided by NPM software registry https://registry.npmjs.org/, it has the public packages that WebMAP needs from third party sources and the licensed packages from Kendo ui for Angular.

To configure the enviroment you first need to override your NPM registry to download the required packages from one of the NPM proxies mentioned above. To perform this change you can configure the workspace by two options.

First option: Set registry directly to WebMAP servers.

This option consist in configure the npm registry to one of the WebMAP npm feeds directly to your global enviroment, if you are an internal developer (VPN connection) to perform the configuration execute the next sentence, please execute using a CMD console run as administrator.

npm set registry http://ais-build-w7:81/npm/Frontend/

In case that you need to install packages from outside organization please execute the next command using a CMD console run as administrator.

npm set registry https://packages.mobilize.net/npm/mobilizenet-npm/ 

Sometimes this command ask for extra information like email, password, username... You can use your GAP Mobilize account information.

Second option: Set registry in the .npmrc user config file and set global registry to public NPM software registry.

This option allows better timing to download packages because it uses the entire network bandwidth, however is not recommended when processes are automated (CI, Azure, TFS, AWS) because can cause network problems. The configuration is set the registry to the global NPM registry, so please execute using a CMD console run as administrator.

npm set registry https://registry.npmjs.org/

Then configure the user .npmrc configuration file in the Windows enviroment, it is placed in the path (Root disk can be C:\, D:\, etc):

C:\Users\<user name>\.npmrc

Inside the file add an specific feed for WebMAP packages, the file only should have one feed to the packages so please remove any other feed related with WebMAP that could appears in the file. File content should look like this if configuration is going to be used inside GAP network:

@mobilize:registry=http://ais-build-w7:81/npm/Frontend/

In case that you need to install packages from outside organization the file should look like this:

@mobilize:registry=https://packages.mobilize.net/npm/mobilizenet-npm/ 

Final steps

After the configuration steps, in any moment developers can retrieve what npm version is configured in their environment executing the next command:

npm get registry

//Theses are possible result values depending of what option you have chosen:
//https://registry.npmjs.org/ -> Second option
//http://ais-build-w7:81/npm/Frontend/ -> First option internal dev (VPN needed)
//https://packages.mobilize.net/npm/mobilizenet-npm -> First option external dev

A very recommeded step is clean clean the project from previous npm feeds or cached packages, the commands to clean are the following:

rimraf .\node_modules\
rimraf .\package-lock.json\
npm cache verify

We recommend the npm package manager but if any other is of your preferece (yarn, pnpm, ect) please read its documentation to determine how to clean the cache and lock files.

Finally you should be able to install packages using the next command:

npm install

Last updated