在脱机计算机上创建NPM注册表的副本? [英] Creating a replica of NPM registry on an offline machine?
问题描述
因此,我需要在独立网络上的独立盒子上进行一些新的Web开发.这个独立的网络无法访问Internet,但是其中有很多计算机可以在Windows Server环境中运行.
So I have a need to do some new web development on a standalone box on a standalone network. This standalone network does not have any access to internet, but there are quite a few machines on it that operate in a Windows Server environment.
我有一台可访问Internet的计算机,可以通过该计算机下载节点并获取软件包,但是我需要能够将软件包整体转移到独立计算机上.
I have an internet-accessible machine with which I could download node and get the packages, but I need to be able to transfer the packages en masse over to the standalone machine.
做到这一点的最佳方法是什么?我已经阅读了一些有关在本地计算机上复制注册表的文档,以便对其进行缓存,但是我将如何获取该缓存并通过USB将其移植到该独立网络?
What's the best way for doing that? I've read a few docs about replicating the registry on a local machine so it caches it, but how would I take that cache and port it over via usb to this standalone network?
还有其他方法可以解决此问题吗?
Are there other methods for handling this?
以前,在另一个项目中,我们使用Verdaccio建立了自己的私有npm存储库,并向该存储库发布了我们自己的npm模块.我可以轻松地进行设置,然后移植到节点模块的tar或zip文件中,然后以这种方式发布它们.但是同样的问题是,如何获得所需的大量节点包?
Previously on a different project, we established our own private npm repo using Verdaccio, and published our own npm modules to that repo. I could easily set that up and then port over tar or zip files of node modules and publish them that way. But again the question is, how do I get the bulk of node packages I need?
我需要知道的主要事情是,一旦复制了所有模块,如何获取本地缓存的npm注册表并将其设置在独立的计算机上.我可以在Internet上完成所有操作,但是如何在服务器上进行传输和复制呢?
The main thing I need to know is how to take this locally cached npm registry and set it up on a standalone machine once all the modules are copied. I can do that all on the internet box, but how would I transfer and replicate all on the server?
推荐答案
我有同样的问题.
我安装并使用verdaccio
并解决了我的问题.
I install and use the verdaccio
and resolved my problem.
感谢胡安·皮卡多
您需要的是正确地缓存您存储文件夹中的所有依赖项.
what you need is cache properly all dependencies in your storage folder.
请参见此处如何找到它
(e.g in windows 8.1
:C:\ Users \ xxx \ AppData \ Roaming \ npm-cache)
(e.g in windows 8.1
: C:\Users\xxx\AppData\Roaming\npm-cache)
您应该能够在缓存中查看所有已解决的依赖性.
You should be able to see all the resolved dependencies in the cache.
然后在路径中设置名称为XDG_DATA_HOME
的Environment variable
:
then set Environment variable
with name: XDG_DATA_HOME
in follow path:
- 右键单击MyComputer
- 点击属性.
- 从左侧面板中,单击
Advance system settings
. - 从
Advance
选项卡中单击Environmrnt variable ...
按钮. - 在新打开的源中,在
system variable
组中.点击new
按钮. - 输入
XDG_DATA_HOME
到Variable name
,并缓存路径到Variable value
. - 单击
Ok
按钮.
- right click on MyComputer
- click properties.
- from left panel, click
Advance system settings
. - from
Advance
Tab clickEnvironmrnt variable ...
button. - in new opened from, in
system variable
group. clicknew
button. - enter
XDG_DATA_HOME
toVariable name
and cache path toVariable value
. - click
Ok
button.
现在,转到config.yaml
,并在packages
部分中注释proxy
.遵循此:
now, go to config.yaml
and comment proxy
in packages
section. follow this:
packages:
'@*/*':
access: $all
publish: $authenticated
# proxy: npmjs
'**':
access: $all
publish: $authenticated
# proxy: npmjs
更改注册表配置网址.
npm config set registry http://localhost:4873/
最后,重新启动verdaccio.
finnally, restart verdaccio.
我希望是有用的.
这篇关于在脱机计算机上创建NPM注册表的副本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!