nodist npm matchのエラーでnpmをバージョンアップできなくて困った話

どうも、Tです。

フロントエンドの勉強のためにnodistなるものを触っていたのですが、エラーがでて困りました。絶対次セットアップするとき忘れるので備忘録。

スポンサーリンク
アドセンス1

事象

npmのバージョンをアップしたくて、「nodist npm match」コマンドを実施したところ下記のエラーが出力されてしまう。

>nodist npm match
npm match
stream.js:74
      throw er; // Unhandled stream error in pipe.
      ^

Error: Failed to read response from https://codeload.github.com/npm/npm/tar.gz/v6.4.1
    at Request. (C:\Program Files (x86)\Nodist\lib\build.js:110:25)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at Request.onRequestResponse (C:\Program Files (x86)\Nodist\node_modules\request\request.js:954:10)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:188:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:473:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
    at TLSSocket.socketOnData (_http_client.js:362:20)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at TLSSocket.Readable.push (_stream_readable.js:134:10)
    at TLSWrap.onread (net.js:551:20)

環境

  • Windows10:1089
  • nodist:0.8.8

原因

エラーメッセージの下記URLが原因になります。

Error: Failed to read response from https://codeload.github.com/npm/npm/tar.gz/v6.4.1

エラーコードのURLに接続してみると原因がわかりました。

GitHub - npm/npm: This repository is moving to: https://github.com/npm/cli
This repository is moving to: - npm/npm

リポジトリ先を移動したよということなので、リポジトリの変更をすれば大丈夫そうです。

解決方法

「PC->C:->Program Files(x86)->Nodis->lib->npm.js」を開きます。

/**
 * List available NPM versions
 * @return {string}
 */
NPMIST.listAvailable = function(){
  return github.releases.listReleasesAsync({
    owner: 'npm',
    repo: 'cli',
    per_page: '100'
  });
};

下記の部分を変更します。

  • 変更前: repo: ‘npm‘,
  • 変更後: repo: ‘cli‘,

/**
 * Get a download URL for the version
 * @param {string} version
 * @return {string}
 */
NPMIST.downloadUrl = function(version){
  return 'https://codeload.github.com/npm/cli/tar.gz/vVERSION'
    .replace('VERSION',version.replace('v',''));
};

下記の部分を変更します。

  • 変更前:return ‘https://codeload.github.com/npm/npm/tar.gz/vVERSION’
  • 変更後:return ‘https://codeload.github.com/npm/cli/tar.gz/vVERSION’

設定変更する前に、「nodist npm match」を実行すると「PC->C:->Program Files(x86)->Nodis->npmv」フォルダに空フォルダ(画像では6.4.1)ができてしまっているため削除しておきましょう。

>nodist npm match
npm match
'https://codeload.github.com/npm/cli/tar.gz/v6.4.1 [============== ] 4972/5150 KiB 97% 0.1s'
>npm -v
6.4.1

「nodist npm match」が実行できるようになりました。バージョンも上がっています。

これ直さないのか

割と簡単に直せるはずなので放置してる原因を調べてみました。現在(2019年1月時点)で最新の「nodist:0.8.8」を使っていたんですが、リリースが2016年・・・絶賛放置中です。

Pull Requestは上がっているので、修正を待つばかりです。

fixes #219 - installs well npm higher than 6.1.x by osher · Pull Request #221 · nodists/nodist
While downloads have redirection from /npm/npm to /npm/cli, listing available versions brings only versions published on the repo. So we need to download from /...

はて、そもそもnode.jsの管理はほかのソフトが主流になっているのか?Macでhomebrew使っているからWindowsはもう下火なのか・・・・。

まとめ

なんか本題はいる前に、これにえらくはまってしまいました。こんなんばっかりー(´・ω・`)

スポンサーリンク
アドセンス1
アドセンス1
ブログランキング・にほんブログ村へ

シェアする

フォローする