跳到主要内容

在命令行中使用npm 登录

背景: 在本地命令行登录的目的,是为了在本地对注册表进行读写。 常见的读命令是npm install安装依赖 常见的写的命令是npm publish 发布依赖包

登录命令:

npm login --registry=https://registry.modao.cc/npm/

注意: 最好在账户的根目录下(mac是~路径)进行登录。因为登录后,会往~/.npmrc中写入authToken注册表。避免出现项目目录下也有.npmrc文件造成

# .npmrc
//registry.modao.cc/npm/:_authToken=NpmToken.72d9949a-cb79-3808-875e-4f17f3a77dfa
registry=https://registry.modao.cc/npm/

登出命令

npm logout

查看当前本地登录的npm 账号

npm who

补充:

在本地的命令行中使用npm adduser,可以在注册表中创建/注册账号

参考:npm adduser命令