本地 NPM/Atmosphere 包存储库,用于没有互联网访问的 Meteor 应用程序 [英] Local NPM/Atmosphere package repositories for Meteor applications without internet access

查看:78
本文介绍了本地 NPM/Atmosphere 包存储库,用于没有互联网访问的 Meteor 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发 Meteor 应用程序的一个分支Rocket Chat.我需要在隔离的网络上站起来测试和开发应用程序,因此无法访问互联网.

I'm currently working on a fork of the Meteor application Rocket Chat. I have a requirement to stand up the application for testing and development on an isolated network, so no internet access whatsoever.

我不能让它在连接的系统上运行,然后将其批量复制到断开连接的实验室中.相反,我需要能够检出源代码的副本(来自本地 SCM),然后运行 ​​Meteor,让它即时执行所有必要的编译和依赖项解析.

I can't just get it running on a connected system and then copy it wholesale into the disconnected lab. Rather, I need to be able to check out a copy of the source code (from a local SCM) and then run Meteor, letting it perform all necessary compilation and dependency resolution on the fly.

即使它是一个巨大的杂物,我还是希望我可以将 .meteor 文件夹从工作系统直接复制到目标系统上,这样它就已经拥有所有需要的缓存包,因此不需要接触任何存储库.但是,根据我的发现,这只适用于从 Atmosphere 下载的 Meteor 依赖项.

Even though it is a huge kludge, I was hoping that I could just copy the .meteor folder from a working system directly onto the target system so that it would already have a cache of all required packages and therefore not need to reach out to any repositories. However, from what I have found, that only works for Meteor dependencies downloaded from Atmosphere.

在 Rocket Chat 中,有几个私有包(例如 rocketchat-ldap)依赖于 NPM 包(在本例中为 ldapjs).当应用程序运行并构建这些包时,用户主目录中的 .npm 文件夹将填充这些 NPM 包.因此,我尝试将该文件夹与 .meteor 文件夹一起打包以完成相同的任务.

Within Rocket Chat, there are several private packages (such as rocketchat-ldap) that have dependencies on NPM packages (in this case, ldapjs). When the application is run and these packages are built, the .npm folder in the user's home directory gets populated with those NPM packages. So, I tried to package that folder up along with the .meteor folder to accomplish the same task.

不幸的是,当我在离线系统上测试它时,尽管有填充的 .npm 文件夹,但 Meteor 吐出以下错误:

Unfortunately, when I tested it on the offline system, despite having the populated .npm folder, Meteor spits out the following error:

在构建包 Rocketchat:ldap 时:错误:无法安装 npm 依赖项.您是否已连接到互联网?

While building package rocketchat:ldap: error: Can't install npm dependencies. Are you connected to the internet?

很明显,我没有联网 - 有意为之.

Obviously, I'm not connected - by design.

所以,我目前正在研究 Sinopia 以建立 NPM我们本地网络上的存储库镜像可以托管这些依赖项.但是,我不知道我应该如何将 Meteor 指向备用服务器.Meteor 文档包含有关应用程序使用的 Npm.dependsNpm.requires 指令的信息,但我找不到任何有关指定从中查找的 URL 的信息说包.

So, I am currently looking into Sinopia to stand up an NPM repository mirror on our local network that can host these dependencies. However, I have no idea how I'm supposed to point Meteor to the alternate server. The Meteor documentation includes information about the Npm.depends and Npm.requires directives, which the application uses, but I can't find anything about specifying a URL from which to find said packages.

此外,是否可以使用 Atmosphere 包做类似的事情?或者是复制 .meteor 文件夹的唯一方法?比如,是否有一些应用程序可以用来托管一些 Meteor 包?还是我以错误的方式处理这个问题?

Further, is it possible to do something similar with the Atmosphere packages? Or is copying the .meteor folder the only way? As in, is there some application out there that I can use to host some of the Meteor packages? Or am I going about this in the wrong way?

推荐答案

我采用的解决方案并不像我希望的那么优雅,如下所示:

The solution I went with, which isn't as elegant as I'd hoped was the following:

首先,我从工作"系统的用户帐户中复制了 .meteor 文件夹(其中包含 Meteor 可执行文件和所有 Meteor 包从 Atmosphere 下载到断开连接的目标系统的用户帐户.这允许目标系统运行 Meteor.

First, I copied the .meteor folder from the user account of a "working" system (this contains the Meteor executable and all of the Meteor packages downloaded from Atmosphere) to the user account of the disconnected target system. This allowed the target system to run Meteor.

其次,有问题的 NPM 包被直接下载到源中的私有包中,但是源上的 .gitignore 文件被设置为忽略 node_modules 文件夹.所以我改变了它,然后将那些 node_modules 文件夹与应用程序的其余部分一起检查到源代码中.

Second, the NPM packages in question were being downloaded directly into the private packages in the source, but the .gitignore file on the source was set to ignore the node_modules folders. So I altered that and then checked those node_modules folders into the source with the rest of the application.

因此,例如,应用程序源包含一个 /packages/rocketchat-ldap/.npm/package 文件夹.然后,当应用程序使用 meteor 运行时,相关的 NPM 包(例如 ldapjs)将被直接下载到 node_modules 该文件夹结构中的文件夹,此时可以构建私有包.

So, for example, the application source included a /packages/rocketchat-ldap/.npm/package folder. Then, when the application was run using meteor, the associated NPM packages (such as ldapjs) would get downloaded directly into a node_modules folder in that folder structure, at which point the private packages could be built.

现在,Git 中的源代码已经包含了那些下载的包,所以当一个副本被检出到断开连接的目标系统时,不需要下载它们.

Now, the source code in Git already contains those downloaded packages, so when a copy is checked out onto the disconnected target system, there is no need to download them.

幸运的是,这并没有显着增加源文件的大小(仅几百 KB).

Fortunately, this did not increase the size of the source very much (just a few hundred kilobytes).

结果是,当运行meteor在目标系统上运行应用程序时,所有依赖都已经就位,不需要互联网连接.

The result is that when running meteor to run the application on the target system, all dependencies are already in place, and no internet connection is required.

这篇关于本地 NPM/Atmosphere 包存储库,用于没有互联网访问的 Meteor 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆