Reputation: 5194
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 :
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.
First of all, is it a good idea ? (in my point of view if i able to do this, the CD process will be reduced to 2-3 minutes from 20-25 minutes) [ We perform clean build hence agent clears local changes from the repository so npm install
is required]
All the dependencies are of fixed version(no upgradation automatically)
How do I configure npm to store the packages into common folder instead of local node_modules
How do I import packages present in common repository into my angular codebase
Can anyone help me on this . ??
Upvotes: 4
Views: 2471
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
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