artifactory npm repository unable to install

匿名 (未验证) 提交于 2019-12-03 09:06:55

问题:

After I installed Artifactory V5.5.1 and with one-click npm setup. I added it to my npm registry, and use npm install something, gives me Cannot read property 'replace' of null. I checked the ~/.npm/npm/underscore/ directory, it was all empty (artifactory and npm is running behind nginx, and given an internal domain)

I've tried npm v3 and v4, with both node v6 and v8

following are the logs of running npm i underscore

0 info it worked if it ends with ok 1 verbose cli [ '/Users/Joesonw/.nvm/versions/node/v8.4.0/bin/node', 1 verbose cli   '/Users/Joesonw/.nvm/versions/node/v8.4.0/bin/npm', 1 verbose cli   'i', 1 verbose cli   'underscore' ] 2 info using npm@4.6.1 3 info using node@v8.4.0 4 silly install loadCurrentTree 5 silly install readLocalPackageData 6 silly fetchPackageMetaData underscore 7 silly fetchNamedPackageData underscore 8 silly mapToRegistry name underscore 9 silly mapToRegistry using default registry 10 silly mapToRegistry registry http://npm/ 11 silly mapToRegistry data Result { 11 silly mapToRegistry   raw: 'underscore', 11 silly mapToRegistry   scope: null, 11 silly mapToRegistry   escapedName: 'underscore', 11 silly mapToRegistry   name: 'underscore', 11 silly mapToRegistry   rawSpec: '', 11 silly mapToRegistry   spec: 'latest', 11 silly mapToRegistry   type: 'tag' } 12 silly mapToRegistry uri http://npm/underscore 13 verbose request uri http://npm/underscore 14 verbose request no auth needed 15 info attempt registry request try #1 at 13:55:04 16 verbose request id 2cf11cb542a89762 17 http request GET http://npm/underscore 18 http 200 http://npm/underscore 19 verbose headers { date: 'Wed, 17 Jan 2018 05:55:04 GMT', 19 verbose headers   'content-type': 'application/json', 19 verbose headers   'transfer-encoding': 'chunked', 19 verbose headers   connection: 'keep-alive', 19 verbose headers   server: 'Artifactory/5.5.1', 19 verbose headers   'x-artifactory-id': '270f055a61f21c28:-11c3536d:16102a8c182:-8000', 19 verbose headers   etag: '546fb6762c99c7ac3b7648e8dfe320681065d0ba' } 20 silly get cb [ 200, 20 silly get   { date: 'Wed, 17 Jan 2018 05:55:04 GMT', 20 silly get     'content-type': 'application/json', 20 silly get     'transfer-encoding': 'chunked', 20 silly get     connection: 'keep-alive', 20 silly get     server: 'Artifactory/5.5.1', 20 silly get     'x-artifactory-id': '270f055a61f21c28:-11c3536d:16102a8c182:-8000', 20 silly get     etag: '546fb6762c99c7ac3b7648e8dfe320681065d0ba' } ] 21 verbose get saving underscore to /Users/Joesonw/.npm/npm/underscore/.cache.json 22 verbose correctMkdir /Users/Joesonw/.npm correctMkdir not in flight; initializing 23 verbose makeDirectory /Users/Joesonw/.npm creation not in flight; initializing 24 silly makeDirectory /Users/Joesonw/.npm uid: 501 gid: 20 25 silly install normalizeTree 26 silly install loadIdealTree 27 silly install cloneCurrentTreeToIdealTree 28 silly install loadShrinkwrap 29 silly install loadAllDepsIntoIdealTree 30 silly resolveWithNewModule underscore@1.8.3 checking installable status 31 silly currentTree npmtest@1.0.0 32 silly idealTree npmtest@1.0.0 32 silly idealTree └―― underscore@1.8.3 33 silly install generateActionsToTake 34 silly diffTrees action count 1 35 silly diffTrees add underscore@1.8.3 36 silly decomposeActions action count 8 37 silly decomposeActions fetch underscore@1.8.3 38 silly decomposeActions extract underscore@1.8.3 39 silly decomposeActions test underscore@1.8.3 40 silly decomposeActions preinstall underscore@1.8.3 41 silly decomposeActions build underscore@1.8.3 42 silly decomposeActions install underscore@1.8.3 43 silly decomposeActions postinstall underscore@1.8.3 44 silly decomposeActions finalize underscore@1.8.3 45 silly install executeActions 46 silly doSerial global-install 0 47 silly doParallel fetch 1 48 verbose correctMkdir /Users/Joesonw/.npm/_locks correctMkdir not in flight; initializing 49 verbose makeDirectory /Users/Joesonw/.npm/_locks creation not in flight; initializing 50 silly makeDirectory /Users/Joesonw/.npm/_locks uid: 501 gid: 20 51 verbose lock using /Users/Joesonw/.npm/_locks/staging-35a192c1000dd88d.lock for /Users/Joesonw/test/npmtest/node_modules/.staging 52 silly doParallel extract 1 53 silly extract underscore@1.8.3 54 silly addNamed underscore@1.8.3 55 verbose addNamed "1.8.3" is a plain semver version for underscore 56 silly mapToRegistry name underscore 57 silly mapToRegistry using default registry 58 silly mapToRegistry registry http://npm/ 59 silly mapToRegistry data Result { 59 silly mapToRegistry   raw: 'underscore', 59 silly mapToRegistry   scope: null, 59 silly mapToRegistry   escapedName: 'underscore', 59 silly mapToRegistry   name: 'underscore', 59 silly mapToRegistry   rawSpec: '', 59 silly mapToRegistry   spec: 'latest', 59 silly mapToRegistry   type: 'tag' } 60 silly mapToRegistry uri http://npm/underscore 61 verbose addNameVersion registry:http://npm/underscore not in flight; fetching 62 verbose get http://npm/underscore not expired, no request 63 silly mapToRegistry name underscore 64 silly mapToRegistry using default registry 65 silly mapToRegistry registry http://npm/ 66 silly mapToRegistry data Result { 66 silly mapToRegistry   raw: 'underscore', 66 silly mapToRegistry   scope: null, 66 silly mapToRegistry   escapedName: 'underscore', 66 silly mapToRegistry   name: 'underscore', 66 silly mapToRegistry   rawSpec: '', 66 silly mapToRegistry   spec: 'latest', 66 silly mapToRegistry   type: 'tag' } 67 silly mapToRegistry uri http://npm/underscore 68 verbose addRemoteTarball ://npm:80/api/npm/npm/underscore/download/underscore-1.8.3.tgz not in flight; adding 69 verbose stack TypeError: Cannot read property 'replace' of null 69 verbose stack     at cf (/Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/npm-cache-filename/index.js:11:17) 69 verbose stack     at addRemoteTarball (/Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/cache/add-remote-tarball.js:37:13) 69 verbose stack     at /Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/cache/add-named.js:217:9 69 verbose stack     at mapToRegistry (/Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/utils/map-to-registry.js:62:3) 69 verbose stack     at fetchit (/Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/cache/add-named.js:191:7) 69 verbose stack     at /Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/lib/cache/add-named.js:187:21 69 verbose stack     at /Users/Joesonw/.nvm/versions/node/v8.4.0/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:284:29 69 verbose stack     at FSReqWrap.oncomplete (fs.js:152:21) 70 verbose cwd /Users/Joesonw/test/npmtest 71 verbose Darwin 16.7.0 72 verbose argv "/Users/Joesonw/.nvm/versions/node/v8.4.0/bin/node" "/Users/Joesonw/.nvm/versions/node/v8.4.0/bin/npm" "i" "underscore" 73 verbose node v8.4.0 74 verbose npm  v4.6.1 75 error Cannot read property 'replace' of null 76 verbose exit [ 1, true ] 

回答1:

I was running artifactory behind a nginx, and used the confs given by artifactory docs.

It turns out 'X-Artifactory-Override-Base-Url' would mess up with npm.

It would have npm returned package zip file links in url like :// instead of http://



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!