我正在尝试学习gatsbyjs,因此当我使用gatsby-cli@2.4.3创建项目时,我进入新创建的目录并运行npm install
。然后,它显示404错误,试图获取@reach/router@1.2.0
软件包。
当我手动执行npm install --verbose @reach/router@1.2.0
时,我得到了:
npm info it worked if it ends with ok
npm verb cli [ '/home/matfau/.nvm/versions/node/v10.5.0/bin/node',
npm verb cli '/home/matfau/.nvm/versions/node/v10.5.0/bin/npm',
npm verb cli 'install',
npm verb cli '--verbose',
npm verb cli '@reach/router@1.2.0' ]
npm info using npm@6.4.1
npm info using node@v10.5.0
npm verb npm-session 4a9d18b8df999ff8
npm http fetch GET 404 https://registry.npmjs.org/@reach%2frouter 2074ms
npm timing stage:rollbackFailedOptional Completed in 1ms
npm timing stage:runTopLevelLifecycles Completed in 2180ms
npm verb stack Error: 404 Not Found: @reach/router@1.2.0
npm verb stack at fetch.then.res (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:42:19)
npm verb stack at tryCatcher (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
npm verb stack at Promise._settlePromiseFromHandler (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
npm verb stack at Promise._settlePromise (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
npm verb stack at Promise._settlePromise0 (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
npm verb stack at Promise._settlePromises (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
npm verb stack at Async._drainQueue (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
npm verb stack at Async._drainQueues (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
npm verb stack at Immediate.Async.drainQueues [as _onImmediate] (/home/matfau/.nvm/versions/node/v10.5.0/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
npm verb stack at runCallback (timers.js:696:18)
npm verb stack at tryOnImmediate (timers.js:667:5)
npm verb stack at processImmediate (timers.js:649:5)
npm verb cwd /home/matfau/dev/realtraining-gatsby
npm verb Linux 4.15.0-38-generic
npm verb argv "/home/matfau/.nvm/versions/node/v10.5.0/bin/node" "/home/matfau/.nvm/versions/node/v10.5.0/bin/npm" "install" "--verbose" "@reach/router@1.2.0"
npm verb node v10.5.0
npm verb npm v6.4.1
npm ERR! code E404
npm ERR! 404 Not Found: @reach/router@1.2.0
npm verb exit [ 1, true ]
npm timing npm Completed in 2403ms
npm ERR! A complete log of this run can be found in:
npm ERR! /home/matfau/.npm/_logs/2018-10-21T20_28_35_069Z-debug.log
当我尝试用curl -sD - https://registry.npmjs.org/@reach%2frouter -o /dev/null
卷曲包装时,我得到了:
HTTP/2 200
date: Sun, 21 Oct 2018 20:34:19 GMT
content-type: application/json
set-cookie: __cfduid=d77c28ce2e70e2ae3525fb54f39f20e3c1540154057; expires=Mon, 21-Oct-19 20:34:17 GMT; path=/; domain=.registry.npmjs.org; HttpOnly
age: 899341
cf-ray: 46d6810d3ee842b5-OSL
etag: W/"4bd43800e5b915de556ca0740caf5d47"
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
last-modified: Tue, 25 Sep 2018 16:59:20 GMT
vary: Accept, Accept-Encoding
via: 1.1 varnish (Varnish/5.2)
x-amz-meta-rev: 20-12439c265d175add79de2380a5d8c405
x-varnish: 159054570 105803757
server: cloudflare
npm config get registry
给了我https://registry.npmjs.org/
npm install jquery
,那么我就不会出错。问题是,为什么会出现404错误,我可以检查什么以进一步调试此问题?
答案 0 :(得分:0)
今天,我连续第四天或第五天再次尝试使用与上面列出的版本相同的npm版本,但突然就可以使用了。至少现在我可以继续学习盖茨比的任务,但是来自Maven宇宙的这种魔术行为使我有些害怕。
答案 1 :(得分:0)
我运行npm login
并创建了用户名和密码,从而解决了到达路由器问题。