programoholic
programoholic

Reputation: 5194

NPM: Can we store node_modules into a common folder and use it in Angular projects?

Can we store node_modules into a common folder instead of local repository folder(node_modules) and then use this common folder into angular project? i will explain my requirement via a flowchart : enter image description here

I know its recommended that we are highly encouraged to place the dependencies locally in node_modules folders so that they will be loaded faster, and more reliably. But still i am trying to create a common local repo(like m2 in maven) which contains modules locally.

Can anyone help me on this . ??

Upvotes: 4

Views: 2471

Answers (2)

programoholic
programoholic

Reputation: 5194

I was finally able to achieve this by implementing Yarn.

We have to set cache path as . :

yarn config set cache-folder /usr/local/Caches/yarn

After implementing this. I was able to successfully achieve the above mentioned requirement.

Upvotes: 5

Suresh Kumar Ariya
Suresh Kumar Ariya

Reputation: 9784

Option1:

You can move the node_modules folder inside src/lib folder and update package.json to point to local src/lib path. For this to achieve, we need to use yarn.

Option2:

You can move all the node_modules to your custom git repo, modify the checkout path to custom git repo in package.json/config.xml. During npm install , it will load from custom git repo.

how to specify local modules as npm package dependencies

Upvotes: 0

Related Questions