@0xproject/npm-cli-login

中文文档
0.0.11发布于 2018/10/17Apache-2.0CommonJS近 30 天下载 1768

Allows you to log in to NPM without STDIN, STDOUT. Use in places like CI build systems. Also creates/modifies entries in the ~/.npmrc file for authentication.

原始使用文档

npm-cli-login Build Status

Allows you to log in to NPM without STDIN, STDOUT. Use in places like CI build systems. Also creates/modifies entries in the ~/.npmrc file for authentication.

Installation

npm install -g npm-cli-login

Use -g flag to use npm-cli-login via the CLI

Usage

CLI

npm-cli-login expects the following environment variables to be set before you can use it to authenticate:

  • NPM_USER: NPM username
  • NPM_PASS: NPM password
  • NPM_EMAIL: NPM email
  • NPM_REGISTRY: (optional) Private NPM registry to log in to (Default: https://registry.npmjs.org)
  • NPM_SCOPE: (optional) Private NPM scope
  • NPM_RC_PATH: (optional) Path to a custom .npmrc file you want to update (Default: ~/) (Do note this is the path of the file, not the file itself)

Once the required ones are set, you can just run the following to log in:

npm-cli-login

You can also export variables and run it all in one line:

NPM_USER=testUser NPM_PASS=testPass [email protected] npm-cli-login

There is also support for command line arguments:

  • -u: NPM Username
  • -p: NPM Password
  • -e: NPM Email
  • -r: NPM Registry
  • -s: NPM Scope
  • --quotes: Set to false by default. Specifies whether your auth token requires quotes. This might required when your auth token has special characters, like =, ? etc.
  • --config-path: Set to ~/ by default. Can be used to configure a custom .npmrc file to edit (Do note this is the path of the file, not the file itself)

For example: npm-cli-login -u testUser -p testPass -e [email protected]

Or: npm-cli-login -u testUser -p testPass -e [email protected] -r https://private.npm.com -s @privateNPM --quotes --config-path="./custom/path/"

Do note that at least one of the two ways must be configured, that is, you must either provide the required fields (username, password and email) using the environment variables or the command line arguments (or both)

Programmatic API

To use the package programmatically, just require the module and pass in your NPM auth details as arguments:

var npmLogin = require('npm-cli-login');
npmLogin(username, password, email [, registry, scope, quotes, configPath]);
Example

Logging in to the NPM registry:

var npmLogin = require('npm-cli-login'),
    username = 'testUser',
    password = 'testPass',
    email = '[email protected]'

npmLogin(username, password, email)

Logging in to private NPM registries:

var npmLogin = require('npm-cli-login'),
    username = 'testUser',
    password = 'testPass',
    email = '[email protected]',
    registry = 'https://npm.example.com',
    scope = '@myScope',
    quotes = false,
    configPath: './custom/path/'

npmLogin(username, password, email, registry, scope, configPath)

版本与发布记录

@0xproject/npm-cli-login 共发布 1 个版本,首次发布于 2018/10/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.11latest2018/10/178 年前

关于 @0xproject/npm-cli-login 的常见问题

@0xproject/npm-cli-login 是什么?

Allows you to log in to NPM without STDIN, STDOUT. Use in places like CI build systems. Also creates/modifies entries in the ~/.npmrc file for authentication.

如何安装 @0xproject/npm-cli-login?

在项目目录运行 npm install @0xproject/npm-cli-login,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 npm-cli-login,可以用 npx npm-cli-login 直接运行。

@0xproject/npm-cli-login 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/0xproject__npm-cli-login 是否存在。

@0xproject/npm-cli-login 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@0xproject/npm-cli-login 可以商用吗?

@0xproject/npm-cli-login 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@0xproject/npm-cli-login 的下载量有多少?

根据 npm 官方下载统计,@0xproject/npm-cli-login 在 2026/10/04 – 2026/11/02 这 30 天内被下载 1,768 次,日均约 59 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@0xproject/npm-cli-login 还在维护吗?

最新版本 0.0.11 发布于 2018/10/17(8 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/10/17。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。