简体   繁体   English

带脱机纱的Angular CLI

[英]Angular CLI with Yarn Offline

Is it possible to have yarn's offline mode be the default, without the need to specify "--offline"? 是否可以将yarn的离线模式设置为默认模式,而无需指定“ --offline”?

For an Angular project, I've set yarn as the package manager using: 对于Angular项目,我使用以下命令将yarn设置为程序包管理器:

 ng set --global packageManager=yarn

I then performed steps to grab all required @angular/cli resources and their dependencies and stored them into the yarn cache, setting the cache location and performing add's such as 然后,我执行步骤以获取所有必需的@ angular / cli资源及其依赖项,并将它们存储在yarn缓存中,设置缓存位置并执行add等操作

yarn add @angular/cli --offline

When running ng new my-app I'd like the dependency resolution to occur using those offline, cached yarn dependencies, yet I'm not able to inform angular that this is desired. 当运行ng new my-app我希望使用那些脱机的,缓存的纱线依赖项来进行依赖项解析,但是我无法告知angular这是需要的。 Ideally, I'd hope it'd be possible to run a command such as 理想情况下,我希望可以运行以下命令

ng new my-project --offline

Is there a way of accomplishing this? 有没有办法做到这一点?

I did it in a different way by creating a local mirror cache directory for the offline installation. 我通过为脱机安装创建本地镜像缓存目录以不同的方式进行了此操作。 I blogged about it here: https://yakovfain.com/2017/12/09/offline-generation-of-angular-cli-projects-with-yarn/ 我在这里写了关于它的博客: https : //yakovfain.com/2017/12/09/offline-generation-of-angular-cli-projects-with-yarn/

Found out that the default setting can be placed in the .yarnrc config file as: 发现默认设置可以放在.yarnrc配置文件中,如下所示:

--*.offline true

This will cause yarn to always prefer the cached libraries when configuring apps that it manages. 这将导致yarn在配置它管理的应用程序时始终偏爱缓存的库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM