LoginSignup
Zect
@Zect

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

[Vue.js] This dependency was not found: firebase

発生したこと

Vue.jsでfirebaseでログインシステムを作ろうと思い、下の記事を見ながらプロジェクトを作成、

以下のリンクにあるコードをローカルにコピペしました。

その後、作業用ディレクトリで

npm run dev

を叩いたところ、以下のようなエラーが出ました。

発生している問題・エラー

 ERROR  Failed to compile with 3 errors

This dependency was not found:

* firebase in ./src/main.js, ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue and 1 other

To install it, you can run: npm install --save firebase
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'
Error from chokidar (C:\node_modules): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'

自分で試したこと

To install it, you can run: npm install --save firebase

と書いてあったので、npm install --save firebaseを実行しましたが、意味なし。

一応、/node_modules を完全削除し、npm iを実行したりもしましたが、成果なしでした。

npmのキャッシュ削除も行ってみましたが、何も変わりませんでした。

リソースモニターでC:\DumpStack.log.tmpに関連付けられたハンドルを検索してみましたが、関連付けられたハンドルは見つかりませんでした。

ネットで調べても、肝心な回答が見つかりませんでした。
(調べ方が悪いのかも)

環境

windows10

C:\> node -v
v16.10.0

C:\> npm -v
8.0.0

C:\> vue -V
@vue/cli 4.5.13

package.json
package.json
{
  "name": "vue_firebase_auth_test",
  "version": "1.0.0",
  "description": "A Vue.js project",
  "author": "Zect",
  "private": true,
  "scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js",
    "start": "npm run dev",
    "lint": "eslint --ext .js,.vue src",
    "build": "node build/build.js"
  },
  "dependencies": {
    "firebase": "^9.2.0",
    "vue": "^2.5.2",
    "vue-nl2br": "^0.1.2",
    "vue-router": "^3.0.1"
  },
  "devDependencies": {
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.22.1",
    "babel-eslint": "^8.2.1",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.1",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-plugin-transform-vue-jsx": "^3.5.0",
    "babel-preset-env": "^1.3.2",
    "babel-preset-stage-2": "^6.22.0",
    "chalk": "^2.0.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "eslint": "^4.15.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-node": "^5.2.0",
    "eslint-plugin-promise": "^3.4.0",
    "eslint-plugin-standard": "^3.0.1",
    "eslint-plugin-vue": "^4.0.0",
    "extract-text-webpack-plugin": "^3.0.0",
    "file-loader": "^1.1.4",
    "friendly-errors-webpack-plugin": "^1.6.1",
    "html-webpack-plugin": "^2.30.1",
    "node-notifier": "^5.1.2",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.0.0",
    "postcss-loader": "^2.0.8",
    "postcss-url": "^7.2.1",
    "rimraf": "^2.6.0",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "uglifyjs-webpack-plugin": "^1.1.1",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.3.0",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "webpack": "^3.6.0",
    "webpack-bundle-analyzer": "^2.9.0",
    "webpack-dev-server": "^2.9.1",
    "webpack-merge": "^4.1.0"
  },
  "engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

0

1Answer

@Zect
僕も同様の問題を抱えていたのですが、先ほど解決しましたので共有いたします。

原因はfirebaseのversion9でapiが変更してためです。今回の変更で必要なコンポーネントごとにimportすることになったので、version8以前を利用している記事をそのまま利用するとエラーが起きてしまいます。

firebaseの公式ページでimportのやり方を確認し、その後、firebase v9を使用したプロジェクトのブログ(以下リンク)などを参考にするとよいと思います。

1Like

Comments

  1. @Zect

    Questioner
    回答ありがとうございます。

    よくfirebaseの公式ドキュメント読んでみると、確かに自分が使用していた記事とimportの仕方が違いますね。もっと公式ドキュメントを読むべきでした...
    まとめ記事の方もありがとうございます。

Your answer might help someone💌