「よーし、Rails API × Vue.jsで簡単なTodoアプリ的なものを実装しよ」
・・・10分後・・・
「非同期でHTTP通信したいときには一般的にaxios
を使うのね。よーし、インストールしてみよ〜」ポチッと
ターミナル
❯ npm install --save axios
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/@vue%2fvue-loader-v15 - Not found
npm ERR! 404
npm ERR! 404 '@vue/vue-loader-v15@15.9.8' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 It was specified as a dependency of '@vue/cli-service'
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
「ほえ?なんだこれは...最近Vue.jsとやらを触り始めたばかりなんだが...」
結論
結論としてはvue-loader-v15
がnpm
のregistry
からセキュリティ上の理由により削除されたためのようですね〜
Nodeのバージョンを上げるか、yarn
コマンドで実行すると上手くいくみたいです。
ターミナル
$ yarn add axios
ターミナル
$ yarn add axios
yarn add v1.22.17
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
success Saved lockfile.
success Saved 5 new dependencies.
info Direct dependencies
└─ axios@0.27.2
info All dependencies
├─ asynckit@0.4.0
├─ axios@0.27.2
├─ combined-stream@1.0.8
├─ delayed-stream@1.0.0
└─ form-data@4.0.0
✨ Done in 2.52s.
package.json
"dependencies": {
"axios": "^0.27.2",
"core-js": "^3.8.3",
"vue": "^3.2.13",
"vue-router": "^4.0.3",
"vuex": "^4.0.0"
}
「ふぅ〜、これでゴリゴリ進めていくぞ〜」
設定ファイルをいじるやり方もあるみたいです(記事が少し古いのでなんとも言えません)
参考:npmでのインストールが404エラーになってたが原因はregistryの設定ファイルだった