1.下载
官网下载可能很慢,或者直接无法下载,那就自行搜索下载吧。
2. 安装
以nexus-3.19.0-01-win64
为例,下载后解压结构如下图:

进入下图目录:

2.1 不要直接点击nexus.exe
,在该目录下使用命令行运行:nexus.exe /run
。运行时出现异常(编码的问题,不用管;另外安装目录如果有中文,应该也会报错,把目录名称改掉):
java.io.UnsupportedEncodingException:
Encoding GBK is not supported yet (feel free to submit a patch)
2.2 启动后默认的地址是:http://localhost:8081
。nexus
目录下的etc/nexus-default.properties
可以修改监听端口

3.登录

打开http://localhost:8081
,后登录账号。本人自己测的版本nexus-3.19.0-01-win64
,默认用户admin
的初始密码在如下文件中(很多文件都是运行nexus.exe /run
后才生产的哦):

打开上图中的文件,拷贝密码,admin
登录的时候,就输入该密码即可(原样复制粘贴即可,不用考虑加密啥的);登录后,会让你修改密码的

修改完成后,上述的admin.password
文件就会被自动删除的哦!
登录完成后,才会出现下图中的设置按钮。

登录后,还可以添加其他用户

4. 创建仓库

点击按钮create repository

npm
相关的仓库类型:
① hosted
宿主仓库:主要用于部署无法从公共仓库获取的构件以及自己或第三方的项目构件;

② proxy
代理仓库:代理公共的远程仓库;

③ group
仓库组:Nexus
通过仓库组统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。【简单的说,就是你可以上传私有的项目到hosted
,以及配置proxy
以获取第三方的依赖(比如可以配置中央仓库的地址)。前面两个都弄好了之后,在通过group
聚合给客户提供统一的访问地址。】

查看新建的三个仓库

点击npm-public
可以看到

5. 配置权限

6. 配置npm
直接执行命令:
npm config set registry http://localhost:8081/repository/npm-public/

发包啥的,可以参照:将自己的vue组件发布为npm包
命令行里注册用户(这里报错了):

用户管理添加用户(相同的用户名、密码可以添加):

但是,登录后,发布包还是报错了

注意(该段说法还有待完整的验证):当
npm adduser
【不存在的用户注册,已存在的用户登录】和npm login
【登录】时,操作的仓库可以是group
,但是npm publish
只能操作hosted
。而上述我们操作的都是group
:npm-public
;改成npm_ginna
即可。下面我们试试吧。

为啥还是报401呢?没有权限呗,看下图,为匿名用户的这个选项打上勾即可(我自己测试还是不行,允许游客install
也得勾选该项;另外的有时间再研究研究吧...)。

发包:npm publish

去到管理页面本地仓库下看看效果吧

在仓库组group
中也可以看到

cnpm搭建私服可以了解下
node.js
修改全局安装文件路径
不小心被自己改了全局路径,重新搜了下怎么改回来,这里做个记录。
在进行 node.js
的开发过程中,我们需要下载大量的依赖模块,为了不让 c
盘的东西太过于散乱,可以通过修改node
的配置参数,来修改node
依赖的下载路径。步骤:
①创建两个文件夹:node_global_modules
、node_cache

② 执行命令:
//我自己本地一般直接设置到nodejs
//npm config set prefix="F:\Program Files\nodejs
npm config set prefix="F:\Program Files\nodejs\node_global_modules"
npm config set cache="F:\Program Files\nodejs\node_cache"
提示
这里另外再加个关于package.json
的提示:
不相干的链接不要随意放上去,会报错的哦!
网友评论