[英]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? 我们可以将node_modules存储到公共文件夹而不是本地存储库文件夹(node_modules)中,然后将此公共文件夹用于角度项目吗? 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 . 我知道它建议我们强烈建议将依赖项放在node_modules文件夹中,以便更快,更可靠地加载它们 。 But still i am trying to create a common local repo(like m2 in maven) which contains modules locally.
但我仍然试图在本地创建一个包含模块的公共本地仓库(如maven中的m2)。
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] (在我看来,如果我能够做到这一点,CD过程将从20-25分钟缩短到2-3分钟)[我们执行干净构建因此代理清除存储库中的本地更改,因此需要
npm install
]
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 如何配置npm以将包存储到公共文件夹而不是本地node_modules
How do I import packages present in common repository into my angular codebase 如何将公共存储库中存在的包导入我的角度代码库
Can anyone help me on this . 谁可以帮我这个事 。 ??
??
I was finally able to achieve this by implementing Yarn. 我终于能够通过实施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.
我能够成功地达到上述要求。
Option1: 选项1:
You can move the node_modules folder inside src/lib folder and update package.json to point to local src/lib path. 您可以在src / lib文件夹中移动node_modules文件夹并更新package.json以指向本地src / lib路径。 For this to achieve, we need to use yarn.
为此,我们需要使用纱线。
Option2: 选项2:
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. 您可以将所有node_modules移动到自定义git仓库,修改package.json / config.xml中自定义git仓库的签出路径。 During npm install , it will load from custom git repo.
在npm安装期间,它将从自定义git repo加载。
how to specify local modules as npm package dependencies 如何将本地模块指定为npm包依赖项
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.