npm私库搭建

首先,分享一下,nexus的说明文档。nexus官网的文档说明这个连接中的help,打开,而后右侧有个能够打开的连接Repository Management With Nexus - free comprehensive book,打开后,你会发现这里是不一样版本的文档说明,以下图。node

这里写图片描述

而后能够选择你正在试用的Nexus Repository Manager的版本进行查看,咱们使用的是3.0版本的,而后在第10章是专门介绍npm私服的。npm

Nexus Repository Manager中添加npm私服

  • 在Nexus Repository Manager中的设置中点击create repositories 按钮。

这里写图片描述

  • 这里面一共有3中类型的npm仓库:ide

    • Proxying npm Registries 代理仓库grunt

      To reduce duplicate downloads and improve download speeds for your developers and CI servers, you should proxy the registry hosted at https://registry.npmjs.org. By default npm accesses this registry directly. You can also proxy any other registries you require. 
      大体的意思就是说,能够访问远程仓库的一些代码,好比angular的代码测试

    • Private npm Registries 托管仓库ui

      A private npm registry can be used to upload your own packages as well as third-party packages. You can create a private npm registry by setting up a hosted repository with the npm format in the repository manager. It is good practice to create two separate hosted repositories for these purposes. 
      大体的意思是说,这是你的私服,能够放你要放到本身的npm私服上的代码this

    • Grouping npm Registries 存储库组(不知道这样翻译怎么样)命令行

      A repository group is the recommended way to expose all your npm registries repositories from the repository manager to your users, without needing any further client side configuration. A repository group allows you to expose the aggregated content of multiple proxy and hosted repositories with one URL to npm and other tools. 
      这是一个综合性的库组,能够将请两个综合起来,下面有详细的介绍。翻译

  • 建立Proxying npm Registries 代理仓库。3d

    • 将标红的三个地方填写好。

    Proxying npm Registries建立时须要填写的地方

    • 一样是填写标红的地方。name and blob store便可。

       建立Proxying npm Registries hosted本地仓库。

  • 建立 Grouping npm Registries 综合仓库

    • 这是将强两个单独的仓库合并起来。

    这里写图片描述

  • 到这里,已经完成了50%了。好了,咱们来看一下,建立好的npm私服。

    • 这里写图片描述
  • 接下来,咱们须要配置一下npm 

  • win + R 打开window 命令行,设置 离线库地址:  npm config set registry http://localhost:8081/repository/npm-all/  (这个就是合并起来的那个路径地址,进到本身group里面查看这个地址)
  • npm config ls  查看本地地址是否已经替换成了离线库地址

到这里,npm的私服建立完毕,接下来,咱们要验证一下了。

验证npm私服是否建立成功

随便在一个目录下,进入cmd,而后执行npm –loglevel info install grunt,看看是够可以下载成功,只是下载成功是不够,还要看下,是否是从你的npm私服中进行下载的。

下图是下载成功,在对应目录下会多一个文件node_modules,注意,你须要删除,由于是测试的

这里写图片描述

 

还须要验证是不是从npm私服中下载的。

这里写图片描述

ok。到这里结束了,个人泪啊,但愿能给你帮助!

相关文章
相关标签/搜索