# npm

# 仓库建立

登录之后进入配置页(导航栏上面点击齿轮按钮),进入Repositories菜单,点击Create repository按钮。

选择npm(hosted)之后,输入Name仓库名称。然后Deployment policy选择Allow redeploy,表示允许更新推送。完成后点击保存。

选择npm(proxy)之后,输入Name仓库名称。然后Remote storage输入https://registry.npmmirror.com,使用阿里云的镜像。完成后点击保存。

选择npm(group)之后,输入Name仓库名称。然后Member repositories选择刚刚的两个库,注意hosted在上,表示优先获取。完成后点击保存。

# 使用私服

通过命令行设置地址为刚刚的group地址

npm config set registry=http://xx/repository/group-npm/

# 登录私服

npm login --registry=http://xx/repository/group-npm/

# 发布到私服

通过命令行设置地址为刚刚的hosted地址

npm publish --registry=http://xx/repository/hosted-npm/

或者

{
  "name": "test-nexus-npm-project",
  "version": "1.0.1",
  "description": "",
  "private": false,
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT",
  "publishConfig": {
    "registry": "http://xxx:xxxx/repository/test-npm-hosted/"
  }
}

# 引入依赖

进入Nexus,点击Browse浏览仓库,进入刚刚的hosted仓库,找到需要引用的包,根据Usage的提示进行应用

{
  "name": "npm_use",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "test-nexus-npm-project": "^1.0.3"
  },
  "author": "",
  "license": "ISC"
}
const sum = require('test-nexus-npm-project')
console.log(sum(1,2))

# Maven

# 仓库建立

# To Be Continued!😎

Last Updated: 5/20/2022, 5:33:47 PM