2023/09/02

使用Nexus Repository 3.59.0-01 作為 NPM Registry 倉庫 上傳及安裝

首先寫好package.json的檔案:
{
  "name": "test",
  "version": "0.0.1",
  "description": "Test npm",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "homepage": "https://xxxxx",
  "keywords": [],
  "author": {
    "name": "Peter Fang",
    "email": "xxxxxx@gmail.com"
  },
  "repository": {
    "type": "git",
    "url": "git+https://xxxxx@bitbucket.org/xxxxxx/xxxxx.git"
  },
  "license": "BSD"
}


接著在要上傳的package輸入 先登入Nexus Repository,他會在.npmrc建立這些資訊
npm adduser --registry https://xxxxx.com/repository/NPM_Web/

不知道.npmrc在哪可以輸入
npm config list



接著上傳即可
npm publish --registry https://xxxxx.com/repository/NPM_Web/


安裝套件輸入
npm --registry https://xxxxx.com/repository/NPM_Web/ install package-name/