当连接到Nexus 3时,npm返回404和405错误

时间:2016-09-22 18:27:39

标签: node.js npm nexus nexus3

背景

我有一个新安装的Nexus OSS 3,我已经配置了一个存储库来代理官方NPM存储库。我添加了用户并将'npm Bearer Token Realm'添加到我的活动领域列表中。存储库状态为“在线 - 远程连接待处理...”,我正在尝试连接的用户目前具有管理员访问权限。

问题:

我正在尝试从两个不同的系统登录到repo,每个系统使用不同版本的节点0.10.x(当前需要开发需要)和npm(一个与节点打包在一起,一个更新为当前版本)。在一个系统上,我得到405错误,输出如下:

    ~$ npm login --loglevel verbose --registry=https://repo.xxx.com/repository/xxxx-npm/
    npm info it worked if it ends with ok
    npm verb cli [ '/usr/local/bin/node',
    npm verb cli   '/usr/local/bin/npm',
    npm verb cli   'login',
    npm verb cli   '--loglevel',
    npm verb cli   'verbose',
    npm verb cli   '--registry=https://repo.xxx.com/repository/xxx-npm/' ]
    npm info using npm@1.4.28
    npm info using node@v0.10.36
    npm verb config Skipping project config: /home/ubuntu/.npmrc. (matches userconfig)
    Username: (user.name) 
    Password: (or leave unchanged) 
    Email: (this IS public) (user.name@xxx.com) 
    npm verb adduser before first PUT { name: 'user.name',
    npm verb adduser   password: 'XXXXX',
    npm verb adduser   email: 'user.name@xxx.com',
    npm verb adduser   _id: 'org.couchdb.user:user.name',
    npm verb adduser   type: 'user',
    npm verb adduser   roles: [],
    npm verb adduser   date: '2016-09-22T17:41:52.249Z' }
    npm verb request where is /-/user/org.couchdb.user:user.name
    npm verb request registry https://repo.xxx.com/
    npm verb request id f911025c53b0616e
    npm verb url raw /-/user/org.couchdb.user:user.name
    npm verb url resolving [ 'https://repo.xxx.com/',
    npm verb url resolving   './-/user/org.couchdb.user:user.name' ]
    npm verb url resolved https://repo.xxx.com/-/user/org.couchdb.user:user.name
    npm verb request where is https://repo.xxx.com/-/user/org.couchdb.user:user.name
    npm info trying registry request attempt 1 at 10:41:52
    npm http PUT https://repo.xxx.com/-/user/org.couchdb.user:user.name
    npm http 405 https://repo.xxx.com/-/user/org.couchdb.user:user.name
    npm verb headers { date: 'Thu, 22 Sep 2016 17:41:52 GMT',
    npm verb headers   server: 'Nexus/3.0.2-02 (OSS)',
    npm verb headers   'x-frame-options': 'SAMEORIGIN',
    npm verb headers   'x-content-type-options': 'nosniff',
    npm verb headers   connection: 'close' }
    npm verb adduser back [ '405 Method Not Allowed', null, undefined ]
    npm ERR! 405 Method Not Allowed
    npm verb exit [ 1, true ]
    npm ERR! not ok code 0

在第二个系统上,我得到404错误,输出如下:

    npm login --registry=https://repo.xxx.com/repository/xxx-npm/
    Username: user.name
    Password: 
    Email: (this IS public) user.name@xxx.com

    npm ERR! Linux 3.13.0-91-generic
    npm ERR! argv "node" "/home/ubuntu/nvm/v0.10.46/bin/npm" "login" "--registry=https://repo.xxx.com/repository/xxx-npm/"
    npm ERR! node v0.10.46
    npm ERR! npm  v3.10.8
    npm ERR! code E404

    npm ERR! 404 Not Found

    npm ERR! Please include the following file with any support request:
    npm ERR!     /home/ubuntu/xvela-app/npm-debug.log

以下是该尝试的npm-debug.log:

    0 info it worked if it ends with ok
    1 verbose cli [ 'node',
    1 verbose cli   '/home/ubuntu/nvm/v0.10.46/bin/npm',
    1 verbose cli   'login',
    1 verbose cli   '--registry=https://repo.xxx.com/repository/xxx-npm/' ]
    2 info using npm@3.10.8
    3 info using node@v0.10.46
    4 verbose adduser before first PUT { _id: 'org.couchdb.user:user.name',
    4 verbose adduser   name: 'user.name',
    4 verbose adduser   password: 'XXXXX',
    4 verbose adduser   email: 'user.name@xxx.com',
    4 verbose adduser   type: 'user',
    4 verbose adduser   roles: [],
    4 verbose adduser   date: '2016-09-22T16:37:53.671Z' }
    5 verbose request uri https://repo.xxx.com/repository/xxx-npm/-/user/org.couchdb.user:user.name
    6 verbose request new user, so can't send auth
    7 info attempt registry request try #1 at 16:37:53
    8 verbose request id e00f9c93ae664e01
    9 http request PUT https://repo.xxx.com/repository/xxx-npm/-/user/org.couchdb.user:user.name
    10 http 404 https://repo.xxx.com/repository/xxx-npm/-/user/org.couchdb.user:user.name
    11 verbose headers { date: 'Thu, 22 Sep 2016 16:37:54 GMT',
    11 verbose headers   server: 'Nexus/3.0.2-02 (OSS)',
    11 verbose headers   'x-frame-options': 'SAMEORIGIN',
    11 verbose headers   'x-content-type-options': 'nosniff',
    11 verbose headers   connection: 'close' }
    12 verbose request invalidating /home/ubuntu/.npm/repo.xxx.com/repository/xxx-npm/-/user/org.couchdb.user_3Auser.name on PUT
    13 verbose adduser back [ { [Error: 404 Not Found] statusCode: 404, code: 'E404' },
    13 verbose adduser   null,
    13 verbose adduser   undefined ]
    14 verbose stack Error: 404 Not Found
    14 verbose stack     at makeError (/home/ubuntu/nvm/v0.10.46/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:302:12)
    14 verbose stack     at CachingRegistryClient.<anonymous> (/home/ubuntu/nvm/v0.10.46/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:253:9)
    14 verbose stack     at Request._callback (/home/ubuntu/nvm/v0.10.46/lib/node_modules/npm/node_modules/npm-registry-client/lib/request.js:210:14)
    14 verbose stack     at Request.self.callback (/home/ubuntu/nvm/v0.10.46/lib/node_modules/npm/node_modules/request/request.js:187:22)
    14 verbose stack     at Request.emit (events.js:98:17)
    14 verbose stack     at Request.<anonymous> (/home/ubuntu/nvm/v0.10.46/lib/node_modules/npm/node_modules/request/request.js:1044:10)
    14 verbose stack     at Request.emit (events.js:95:17)
    14 verbose stack     at IncomingMessage.<anonymous> (/home/ubuntu/nvm/v0.10.46/lib/node_modules/npm/node_modules/request/request.js:965:12)
    14 verbose stack     at IncomingMessage.emit (events.js:117:20)
    14 verbose stack     at _stream_readable.js:944:16
    15 verbose statusCode 404
    16 verbose cwd /home/ubuntu/xxx-app
    17 error Linux 3.13.0-91-generic
    18 error argv "node" "/home/ubuntu/nvm/v0.10.46/bin/npm" "login" "--registry=https://repo.xxx.com/repository/xxx-npm/"
    19 error node v0.10.46
    20 error npm  v3.10.8
    21 error code E404
    22 error 404 Not Found
    23 verbose exit [ 1, true ]

我已经解决了这个问题,并且Nexus本身没有在其日志中显示任何关于这些连接尝试的证据。任何帮助将不胜感激。

干杯!

1 个答案:

答案 0 :(得分:1)

npm login命令目前不适用于代理npm存储库(但它确实适用于组和托管存储库)。

https://issues.sonatype.org/browse/NEXUS-10149

在3.1版本中修复了这个问题。

尝试将您的代理仓库放入群组仓库,并使用群组repo的网址。