简体   繁体   English

Cloud Functions,Firebase:解析函数触发错误

[英]Cloud Functions, Firebase: parsing function triggers error

i am trying to follow the tutorial at https://codelabs.developers.google.com/codelabs/firebase-cloud-functions/#7 and I am getting the "Error occurred while parsing your function triggers" error. 我试图按照https://codelabs.developers.google.com/codelabs/firebase-cloud-functions/#7上的教程进行操作,但出现“解析函数触发器时发生错误”错误。 firebase-tools verson is 5.6.0. firebase-tools版本为5.6.0。 What I am doing wrong? 我做错了什么?

Stack Trace: 堆栈跟踪:

C:\Users\user\Downloads\friendlychat-web-master\cloud-functions-start\functions>firebase deploy --only functions

=== Deploying to 'friendlychat'...

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...

Error: Error occurred while parsing your function triggers.

C:\Users\user\Downloads\friendlychat-web-master\cloud-functions-start\functions\index.js:23
exports.addWelcomeMessages = functions.auth.user().onCreate(async(user)=>{
                                                                 ^
SyntaxError: Unexpected token (
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at C:\Users\user\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:21:11

functions\\index.js functions \\ index.js

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();    
exports.addWelcomeMessages = functions.auth.user().onCreate(async(user)=>{
    const fullName = user.displayName || 'Anonymous';
      await admin.database().ref('messages').push({
      name: 'Firebase Bot',
      profilePicUrl: '/images/firebase-logo.png', // Firebase logo
      text: `${fullName} signed in for the first time! Welcome!`,
    });
  });

functions\\Package.json: functions \\ Package.json:

{
  "name": "friendlychat-codelab",
  "description": "Firebase SDK for Cloud Functions codelab",
  "dependencies": {
    "firebase-admin": "~5.13.1",
    "firebase-functions": "^2.0.0"
  },
  "devDependencies": {
    "eslint": "^4.12.0",
    "eslint-plugin-promise": "^3.6.0"
  },
  "engines": {
    "node": "8"
  },
  "private": true
}

The instructions at the beginning of the codelab require you to be using nodejs 8. You're probably using an older version, which doesn't support async/await. 代码实验室开头的说明要求您使用nodejs8。您可能正在使用较旧的版本,该版本不支持async / await。

Check your node version with this: 使用以下方法检查您的节点版本:

node --version

It should be version 8. If it's not, you'll have to replace it. 它应该是版本8。如果不是,则必须替换它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Firebase 云函数:“解析 function 触发器时出错” - Firebase Cloud Functions: 'Error occurred while parsing your function triggers' Cloud Functions for Firebase firebase 部署错误:“解析触发器时出错:找不到模块‘firebase-admin’” - Cloud Functions for Firebase firebase deploy error: "Error parsing triggers: Cannot find module 'firebase-admin'" Firebase-节点云功能错误解析触发器:找不到模块“ firebase-functions” - Firebase - Node Cloud Functions Error parsing triggers: Cannot find module 'firebase-functions' 错误:解析触发器错误:找不到模块“ firebase-functions” - Error: Error parsing triggers: Cannot find module 'firebase-functions' 包括异步 Function Firebase Cloud Functions 内(eslint“解析错误:意外的令牌函数”) - Including Async Function Within Firebase Cloud Functions (eslint "Parsing error: Unexpected token function") firebase部署错误:“解析函数触发器时发生错误” - firebase deployment error:“error occured while parsing your function triggers” Firebase 云 Function - 解析错误:意外令牌 => - Firebase Cloud Function - Parsing error: Unexpected token => Firebase的云功能图像下载功能错误 - Cloud Functions for Firebase Image download function Error Firebase 云功能:部署 function 时出错 - Firebase Cloud Functions: Error while deploying function (..)。然后不是函数,firebase云功能 - (..).then is not a function ,firebase cloud functions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM