2

As of now I am installing node modules every time for the new angular project. Is it possible to use one projects node modules to other project by configuring any file(like changing the path in any file so it can use that modules)?

Pujan Shah
  • 775
  • 10
  • 15

2 Answers2

2

First off I was shocked to see that this is actually a thing that some people are doing - see: https://github.com/nodejs/help/issues/681

However I would advise against it.

The idea behind each project having its own node_modules folder (and package.json) is that each of your projects should specify its own dependencies (including specific versions) which is a good thing for stability, predictability, reproducibility, etc. of your various projects. Here's a pretty good write-up on the node dependency model: https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/

Now if you're talking about a local module (that you created yourself), you can have a look at https://docs.npmjs.com/cli/link.html

philarmour
  • 394
  • 5
  • 10
  • basically it should be different only, but as I mentioned for learning purpose there are multiple tasks(application) and all are having the same dependencies then we can create multiple applications in single project. – Pujan Shah Dec 21 '18 at 12:57
2

From Angular 6, you can generate multiple application in a single Angular project.

https://angular.io/cli/generate#application-command

applications generated by Angular cli command stay in same workspace and share node_modules.

For example, if you want to generate app my-project:

ng generate application my-project

If its dependencies are not different from previous one, you can use --skipInstall=true option with ng generate command.

And ng serve it with --project option:

ng serve --project=my-project
zmag
  • 7,825
  • 12
  • 32
  • 42