1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Firebaseでデプロイ(deploy)時に発生したエラーを解決した(しょうもないミスでした)

Posted at

FirebaseでReact+TypeScriptを使用し、deployした際にエラーが発生

エラー内容

=== Deploying to 'test-demo-f9999'...

i  deploying firestore, functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint

> functions@ lint /Users/tarou//test/test-demo/functions
> eslint 'src/**/*'

Running command: npm --prefix "$RESOURCE_DIR" run build

> functions@ build /Users/tarou/test/test-demo/functions
> tsc

✔  functions: Finished running predeploy script.
i  firestore: reading indexes from firestore.indexes.json...

Error: Error reading rules file build

Error reading rules file build

これをみて、最初は意味がわかりませんでしたが、ググりまくってもわからず、
ファイルを見直した際に発覚しました!

原因はfirebase.jsonファイルのrulesの記述をミスっていた


{
  "firestore": {
    "rules": "build",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

よくみてみると、firestoreのrulesがbuild

になってしまっている・・・
下記のように、rurlesをfirestore.rulesに書き換えることにより、解決。


{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint",
      "npm --prefix \"$RESOURCE_DIR\" run build"
    ]
  },
  "hosting": {
    "public": "build",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}

環境設定画面で、記述をミスってしまっていた・・・・。
良い経験になりました。

環境設定時は気を引き締めて進めよう。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?