かりっと揚げたらフライドポテト

㍋出る迄頑張るぞい

npm installでfetch failedするのを治す

raspiにhubotいれて遊ぼうとおもってcoffee-script入れようとする。

apt-getで入るのはバージョンが古くおすすめしないらしいので、npm installでいれることに。
wikiCoffeeScript インストール - sappari wiki


ところが、yoとかgenerator-hubotを入れたときは正常に動いていたnpmがエラーを吐いてきた。localeをいじった関係かもしれない。

npm ERR! Linux 4.4.21-v7+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "coffee-script"
npm ERR! node v7.6.0
npm ERR! npm v4.1.2
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo

npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'

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

こんなのや、

npm ERR! fetch failed https://registry.npmjs.org/coffee-script/-/coffee-script-1.12.4.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443

こんなエラーが!proxyがおかしいとかENOTFOUNDとか言っているが、結局はregistry.npmjs.orgというホスト名が解決できていないということらしい。

そこでgithubのIssueを参考にして/etc/hostsに以下を追記した

npm install giving fetch errors for some packages · Issue #13289 · npm/npm · GitHub

#/etc/hosts

151.101.36.162 registry.npmjs.com

151.101.36.162 registry.npmjs.org

そしてrebootして再度npm installを行うとみごと成功!

なんでこのホスト名が解決できなかったのかは謎...

また、途中紆余曲折して
npm ERR! Cannot read property 'path' of null · Issue #15348 · npm/npm · GitHub
npm ERR! Cannot read property 'path' of null · Issue #15227 · npm/npm · GitHub


あたりを参考にproxyの設定をいじってみたが、全く意味はなかった。そもそもproxyがよくわかっていない(オイ
社内とか学校のネットワーク使用してて同様のエラーが出たときは参考にしてみるといいのかもしれない