返回介绍

PART Ⅰ : 容器云OPENSHIFT

PART Ⅱ:容器云 KUBERNETES

PART Ⅲ:持续集成与持续部署

PART Ⅴ:日志/监控/告警

PART Ⅵ:基础

PART Ⅶ:数据存储、处理

PART VIII:CODE

PART X:HACKINTOSH

PART XI:安全

NPM

发布于 2024-06-08 21:16:46 字数 5122 浏览 0 评论 0 收藏 0

npm config set registry http://nexus-ip-address:8081/repository/npm/

当使用 npm loginnpm adduser 等NPM客户端使用Token进行登录认证到Nexus的NPM仓库时,Nexus默认仅支持Local Authenticating Realm ,认证不了NPM相关token。所以配置Nexus添加npm的认证域。

echo "hello" >> test
npm init
#   package name: (test) sadsada
#   version: (1.0.0)
#   description:
#   entry point: (index.js) test
#   test command:
#   git repository:
#   keywords:
#   author:
#   license: (ISC)
#   About to write to /root/test/package.json:
#   {
#     "name": "sadsada",
#     "version": "1.0.0",
#     "description": "",
#     "main": "f",
#     "scripts": {
#       "test": "echo \"Error: no test specified\" && exit 1"
#     },
#     "author": "",
#     "license": "ISC"
#   }
npm login -registry http://nexus-ip-address:8081/repository/npm-hosted/
# Username: admin
#Password: *****
# Email: (this IS public) asdad@sada.com
npm publish -registry http://nexus-ip-address:8081/repository/npm-hosted/

Github地址:https://github.com/Pana/nrm 帮助快速切换npm仓库源。默认已经配置了npm、yarn、taobao、cnpm、nj、npmMirror、edunpm等常见的仓库源。

1. 安装

npm install nrm -g

2. 命令详解

$ nrm -h
Usage: nrm [options] [command]
Options:
  -V, --version output the version number
  -h, --help output usage information
Commands:
  ls List all the registries
  current Show current registry name
  use <registry> Change registry to registry
  add <registry> <url> [home] Add one custom registry
  set-auth [options] <registry> [value] Set authorize information for a custom registry with a base64 encoded string or username and pasword
  set-email <registry> <value> Set email for a custom registry
  set-hosted-repo <registry> <value> Set hosted npm repository for a custom registry to publish packages
  del <registry> Delete one custom registry
  home <registry> [browser] Open the homepage of registry with optional browser
  publish [options] [<tarball>|<folder>] Publish package to current registry if current registry is a custom registry.
   if you're not using custom registry, this command will run npm publish directly
  test [registry] Show response time for specific or all registries
  help Print this help

3. 常用命令

查看默认支持的npm 仓库

$ nrm ls
* npm -------- https://registry.npmjs.org/
  yarn ------- https://registry.yarnpkg.com/
  cnpm ------- http://r.cnpmjs.org/
  taobao ----- https://registry.npm.taobao.org/
  nj --------- https://registry.nodejitsu.com/
  npmMirror -- https://skimdb.npmjs.com/registry/
  edunpm ----- http://registry.enpmjs.org/
# "*"编注的仓库代表当前使用的仓库

添加私有的npm仓库

nrm add okd-nexus http://nexus-ip-address:8081/repository/npm-hosted/

切换npm仓库

 nrm use 仓库名

删除仓库

 nrm del 仓库名

测试仓库速度

nrm test

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文