Open LOWINC opened 3 years ago
问题
npm ERR! code E400
npm ERR! 400 Bad Request - PUT http://localhost:8888/repository/npm-group/asddadad
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/apple/.npm/_logs/2021-08-13T08_03_26_105Z-debug.log
修改
"publishConfig": {
"registry": "http://localhost:8888/repository/npm-hosted/"
},
npm ERR! code E401
npm ERR! Unable to authenticate, need: BASIC realm="Sonatype Nexus Repository Manager"
指定默认源
$ nrm add nexusNpm --- http://localhost:8888/repository/npm-group/
$ nrm use nexusNpm
禁止匿名用户访问后 推送报错401
由于npm仓库设置了禁止匿名访问,所以在本地登录。
npm adduser --registry=http://localhost:10088/repository/npm-hosted/
npm-dev-1
sunweiqi
123@qq.com
npm Security If enabled, any anonymous user has read access to the repositories and repository groups. If anonymous access, as documented in Anonymous Access, is disabled or write access is required for publishing a package, the user needs to authenticate to the repository manager. There are two methods to authenticate npm with your repository manager. Only one should be used at a time.
Authentication Using Realm and Login This authentication method requires the npm Bearer Token Realm. Simply add the realm to the active realms in the Realms feature of the Security menu from the Administration menu to activate it as documented in Realms.
Once the realm is activated, a npm CLI user can establish the authentication to a repository with the npm adduser ( npm login is an equivalent alias ) command.
npm adduser --registry=http://localhost:8081/repository/npm-hosted/
Provide your repository manager username and password as well as an email address when prompted. Upon successful completion, a line for authentication of this combination is automatically added to your .npmrc configuration file for the specific repository.
Despite its name, the npm adduser command does not actually create a user account inside NXRM. It merely associates a token with an existing user account and allows the CLI to store that token for re-use.
设置私服后 yarn 安装报错:Couldn't find package "lodash-es" on the "npm" registry.
/Users/apple/.npmrc
设置:
always-auth=true
在nexus上配置npm私有仓库
新建三个仓库
项目设置
npm
package.json
业务
.npmrc
用到的命令
先指定当前源
登入
设置权限
Security -> Anonymous 添加登录的user
遇到的问题
登录报错:ENOTFOUND
npm login -d registry=http://localhost:8888/repository/npm-group/
修复方法 编辑host文件 127.0.0.1 -> localhost
拉取推送时401
删除保存的_authToken