Install package that result of a local build of another angular project

752 Views Asked by At

I'm migrationg all my projects from angular 5 to angular 6. I have some projects that dependes on anothers.

I have a project, lets call ProjectA that dependes on ProjectB. I make a build for the ProjectB that results on a group of files on the folder dist.

Usually, when I want to test, I take the files from the folder dist from the ProjectB and put on ProjectA under the folder node_modules. Basiclly I'm making a "manual" instalation of the package ProjectB.

The problem on this scenario is that, when I make npm install, it will be install the latest version of ProjectB and the manual instalation of ProjectB will be losed.

What are my options for this scenario?

2

There are 2 best solutions below

0
On BEST ANSWER

After some search I found out on this post that you can run the following command, and the npm will install local package build as a could package:

npm install /absolute/local/path/to/your/other/package

Important note:

Pay attention to your package.config, because it will be change after installing on this way, for the package that you install using the absolute path folder.

0
On

Take advantage of angular-cli v6 "Library" concept. Migrate your ProjectB as an Angular Library project, your ProjectA as a regular project, and maintain them together. Read the following introductory article to get a better idea:

The Angular Library Series - Creating a Library with the Angular CLI

If you have to maintain A & B as 2 separate repositories, you can add your ProjectB as a GIT submodule for your ProjectA and put it into the correct place. Then use it as a Library project.