# npm-login-registry

> npm login

Latest version **1.1.4** (published 2021-11-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install npm-login-registry
pnpm add npm-login-registry
yarn add npm-login-registry
bun add npm-login-registry
```

Provides the command `npm-login-registry`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2021-11-30 |
| First published | 2021-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | folgerfan |
| Maintainers | folger_fan |
| Keywords | npm login, npm adduser, npm publish |

## Links

- npm: https://www.npmjs.com/package/npm-login-registry
- npm.io page: https://npm.io/package/npm-login-registry

## Dependencies (1)

- [commander](https://npm.io/package/commander.md) ^8.3.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.1.4 (latest) — 2021-11-30
- 1.1.3 — 2021-11-30
- 1.1.2 — 2021-11-30
- 1.1.1 — 2021-11-30
- 1.1.0 — 2021-11-30
- 1.0.0 — 2021-11-30

## README

# 背景

`npm login`是交互式命令，不适用于`ci`场景。希望能有个命令行能一次性输入用户名、密码、邮箱进行登陆，且支持`registry`。

# 原理

现在有个[npm-cli-login](https://www.npmjs.com/package/npm-cli-login)，支持命令行式的一步登陆。看了下源码，是通过`http`调用的方式登陆的。试了下不支持腾讯内部源。

这个库是用代码完成了交互式命令的输入。相当于手动`npm login`。支持官方源(无registry)和配置`registry`。目前只验证了腾讯内部源。

# 参数说明

| 参数       | cli          | cli缩写 | 含义   |
| ---------- | ------------ | ------- | ------ |
| `username` | `--username` | `-u`    | 用户名 |
| `password` | `--password` | `-p`    | 密码   |
| `email`    | `--email`    | `-e`    | 邮箱   |
| `registry` | `--registry` | `-r`    | 源     |

> 官方源不用传`registry`

> 目前只验证了腾讯内部源

# 用法

### 安装

```
npm install -g npm-login-registry
```

### 脚本

```shell
npm-login-registry -u xxx -p xxx -e xxx -r xxx
```

### 代码引用

```js
const npmLogin = require('npm-login-registry');

npmLogin({
  username: 'xxx',
  password: 'xxx',
  email: 'xxx',
  registry: 'xxx'
})
```

### ci示例

```yaml
script:
  - npm install -g npm-login-registry
  - npm-login-registry -u xxx -p xxx -e xxx -r xxx
  - npm publish
```

---
_Source: https://npm.io/package/npm-login-registry · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
