#前提・実現したいこと
以下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!
あなたの回答
tips
プレビュー