質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
bash

bash(Bourne-again-Shell)は sh(Bourne Shell)のインプリメンテーションに様々な機能が追加されたシェルです。LinuxやMac OS XではBashはデフォルトで導入されています。

npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Cloud Firestore

Cloud Firestore は、自動スケーリングと高性能を実現し、アプリケーション開発を簡素化するように構築された NoSQLドキュメントデータベースです。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

Q&A

0回答

1445閲覧

Cloud Functions for Firebaseのデプロイができない

kotatsu828

総合スコア6

bash

bash(Bourne-again-Shell)は sh(Bourne Shell)のインプリメンテーションに様々な機能が追加されたシェルです。LinuxやMac OS XではBashはデフォルトで導入されています。

npm

npmは、Node Packaged Modulesの略。Node.jsのライブラリ・パッケージを管理できるツールです。様々なモジュールを簡単にインストールでき、自分でモジュールを作成し公開する際にも使用できます。

Firebase

Firebaseは、Googleが提供するBasSサービスの一つ。リアルタイム通知可能、並びにアクセス制御ができるオブジェクトデータベース機能を備えます。さらに認証機能、アプリケーションのログ解析機能などの利用も可能です。

Cloud Firestore

Cloud Firestore は、自動スケーリングと高性能を実現し、アプリケーション開発を簡素化するように構築された NoSQLドキュメントデータベースです。

Node.js

Node.jsとはGoogleのV8 JavaScriptエンジンを使用しているサーバーサイドのイベント駆動型プログラムです。

0グッド

0クリップ

投稿2020/06/30 13:34

#前提・実現したいこと
以下2つのサイトを参考にcloud functions for firebaseの環境構築を行なっていますが、デプロイでエラーが発生しており、私がNode.jsなどに関して初心者なので解決できません。
よろしくお願いいたします。

はじめに: 最初の関数の記述とデプロイ
Firebase で Cloud Functions を簡単にはじめよう

基本的には上のリンク(公式のやつ?)に従って進めました。流れは
1.プロジェクト作成
2.Node Version Managerのインストール(v8.17.0)
3.npm install -g firebase-tools(ターミナルで)
4.firebase login(ターミナルで)
公式だとRealtimeDatabaseの例しか描かれていなかったので、
以降は下のリンクのやり方を参考にしました
5.firebaseプロジェクト用のディレクトリを作成し移動
6.firebase init(ターミナルで)
7./functions/index.jsの内容を書き換え(該当のソースコードに記載)
8.firebase deploy(ターミナルで)

#発生している問題・エラーメッセージ

bash

1$ firebase deploy 2 3=== Deploying to '~~~'... 4 5i deploying database, storage, firestore, functions, hosting 6Running command: npm --prefix "$RESOURCE_DIR" run lint 7npm ERR! missing script: lint 8 9npm ERR! A complete log of this run can be found in: 10npm ERR! /Users/~~~/.npm/_logs/2020-06-30T12_46_22_777Z-debug.log 11 12Error: functions predeploy error: Command terminated with non-zero exit code1

#該当のソースコード
index.js

js

1const functions = require('firebase-functions'); 2 3// // Create and Deploy Your First Cloud Functions 4// // https://firebase.google.com/docs/functions/write-firebase-functions 5// 6exports.helloWorld = functions.https.onRequest((request, response) => { 7 response.send("Hello from Firebase!"); 8});

#自分で調べたことや試したこと
エラーの内容でググってみると
initの時に
「Do you want to use ESLint to catch probable bugs and enforce style?」の質問にYes
にすると起こると記載があったのでNoにしたが解決しなかった

? Do you want to use ESLint to catch probable bugs and enforce style? No

#使っているツールのバージョンなど補足情報
OS:macOSX
一度ログインしてからは何度firebase loginしても
Already logged in as ~~~
と出力される

######$ firebase initの結果(ご参考になるかわかりませんが…)
何度も作り直しているので、基本的にはファイルが上書きになっています。

firebase init ######## #### ######## ######## ######## ### ###### ######## ## ## ## ## ## ## ## ## ## ## ## ###### ## ######## ###### ######## ######### ###### ###### ## ## ## ## ## ## ## ## ## ## ## ## #### ## ## ######## ######## ## ## ###### ######## You're about to initialize a Firebase project in this directory: /Users/~~~/Documents/Gotcha_js Before we get started, keep in mind: * You are initializing in an existing Firebase project directory ? Which Firebase CLI features do you want to set up for this folder? Press Space to select features, then Enter to confirm your choices. (Press <space> to selec t, <a> to toggle all, <i> to invert selection)Database: Deploy Firebase Realtime Database Rules, Firestore: Deploy rules and create indexes for Firestore, Funct ions: Configure and deploy Cloud Functions, Hosting: Configure and deploy Fireba se Hosting sites, Storage: Deploy Cloud Storage security rules, Emulators: Set u p local emulators for Firebase features === Project Setup First, let's associate this project directory with a Firebase project. You can create multiple project aliases by running firebase use --add, but for now we'll just set up a default project. i .firebaserc already has a default project, using ~~~. === Database Setup Firebase Realtime Database Rules allow you to define how your data should be structured and when your data can be read from and written to. ? What file should be used for Database Rules? atabase.rules.json ? File database.rules.json already exists. Do you want to overwrite it with the Database Rules for from the Firebase Console? Yes ✔ Database Rules for have been downloaded to database.rules.json. Future modifications to database.rules.json will update Database Rules when you run firebase deploy. === Firestore Setup Firestore Security Rules allow you to define how and when to allow requests. You can keep these rules in your project directory and publish them with firebase deploy. ? What file should be used for Firestore Rules? firestore.rules ? File firestore.rules already exists. Do you want to overwrite it with the Fire store Rules from the Firebase Console? Yes Firestore indexes allow you to perform complex queries while maintaining performance that scales with the size of the result set. You can keep index definitions in your project directory and publish them with firebase deploy. ? What file should be used for Firestore indexes? firestore.indexes.json ? File firestore.indexes.json already exists. Do you want to overwrite it with t he Firestore Indexes from the Firebase Console? Yes === Functions Setup A functions directory will be created in your project with a Node.js package pre-configured. Functions can be deployed with firebase deploy. ? What language would you like to use to write Cloud Functions? JavaScript ? Do you want to use ESLint to catch probable bugs and enforce style? No ? File functions/package.json already exists. Overwrite? Yes ✔ Wrote functions/package.json ? File functions/index.js already exists. Overwrite? Yes ✔ Wrote functions/index.js ? File functions/.gitignore already exists. Overwrite? Yes ✔ Wrote functions/.gitignore ? Do you want to install dependencies with npm now? Yes audited 252 packages in 2.781s 29 packages are looking for funding run `npm fund` for details found 0 vulnerabilities === Hosting Setup Your public directory is the folder (relative to your project directory) that will contain Hosting assets to be uploaded with firebase deploy. If you have a build process for your assets, use your build's output directory. ? What do you want to use as your public directory? public ? Configure as a single-page app (rewrite all urls to /index.html)? No ? File public/404.html already exists. Overwrite? Yes ✔ Wrote public/404.html ? File public/index.html already exists. Overwrite? Yes ✔ Wrote public/index.html === Storage Setup Firebase Storage Security Rules allow you to define how and when to allow uploads and downloads. You can keep these rules in your project directory and publish them with firebase deploy. ? What file should be used for Storage Rules? storage.rules === Emulators Setup ? Which Firebase emulators do you want to set up? Press Space to select emulator s, then Enter to confirm your choices. Functions, Firestore, Database, Hosting, Pubsub i Port for functions already configured: 5001 i Port for firestore already configured: 8080 i Port for database already configured: 9000 i Port for hosting already configured: 5000 i Port for pubsub already configured: 8085 i Emulator UI already enabled with port: (automatic) ? Would you like to download the emulators now? No i Writing configuration info to firebase.json... i Writing project information to .firebaserc... ✔ Firebase initialization complete!

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

w2-yamaguchi

2020/07/02 15:59 編集

pacage.jsonとfirebase.jsonの内容を追記いただけますか?
kotatsu828

2020/07/19 22:19

お返事が遅くなりました。 以下ファイルの内容を追記します。 しかしながら、 firebase.jsonの"functions"の"predeploy"の lintの記述を消したらデプロイできるようになりました、、、 lintの記述は消してしまっても問題はないのでしょうか? 宜しくお願い致します package.json ``` { "name": "functions", "description": "Cloud Functions for Firebase", "scripts": { "serve": "firebase emulators:start --only functions", "shell": "firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log" }, "engines": { "node": "8" }, "dependencies": { "firebase-admin": "^8.10.0", "firebase-functions": "^3.6.1" }, "devDependencies": { "firebase-functions-test": "^0.2.0" }, "private": true } ``` firebase.json ``` { "database": { "rules": "database.rules.json" }, "firestore": { "rules": "firestore.rules", "indexes": "firestore.indexes.json" }, "hosting": { "public": "public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ] }, "storage": { "rules": "storage.rules" }, "emulators": { "functions": { "port": 5001 }, "firestore": { "port": 8080 }, "database": { "port": 9000 }, "hosting": { "port": 5000 }, "pubsub": { "port": 8085 }, "ui": { "enabled": true } }, "functions": { "predeploy": [   //ここを削除 ], "source": "functions" } } ```
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問