Firebase 函数类型错误:无法读取 Google 上操作的未定义属性'stack'



我正在使用Firebase云函数作为webhook来执行我在谷歌对话流实现上的操作。

我的index.js文件如下

'use strict';
process.env.DEBUG = 'actions-on-google:*';
var requestcall = require('request');
var date = require('date-and-time');
var promise = require('promise');
var AmazonDateParser = require('amazon-date-parser');
var moment = require('moment-timezone');
var accountnum;
var accessToken;
var timePeriod;
var acctnums =[];

// Create functions to handle requests here
const WELCOME_INTENT = 'input.welcome';  // the action name from the Dialogflow intent
const NUMBER_INTENT = 'account_number';  // the action name from the Dialogflow intent
const NUMBER_ARGUMENT = 'number'; // the action name from the Dialogflow intent
const OUT_CONTEXT = 'output_context';
const ACCOUNT_ARG = 'info';
const ACCOUNT_NUM = 'myAccountNum';
const AccountNums = 'AccountNums';
const CURRENCY_SYMBOL = 'CurrencySymbol';
const TIME_ZONE = 'TimeZone';
const STATS_ARG = 'nextStatsData';

const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const {
SimpleResponse,
BasicCard,
Image,
Suggestions,
Button
} = require('actions-on-google');
const app = dialogflow(
{debug: true,clientId: 'xxxxxxxxxxx.apps.googleusercontent.com'});
app.middleware((conv) => {

});



app.intent('Default Welcome Intent', (conv) => {


console.log('Request headers: ' + JSON.stringify(conv.headers));
console.log('Request body: ' + JSON.stringify(conv.body));
accessToken =conv.body.originalDetectIntentRequest.payload.user.accessToken;
console.log('accessToken: ' + accessToken);

if (accessToken !== null) {


return  getaccountDetails(conv).then((entity)=>{
return getMessageFromAccount(entity,conv);
});



}
else{

return conv.close(new SignIn('To get your account details'));


}


});
exports.stats = functions.https.onRequest(app);

我的package.json文件如下

"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"actions-on-google": "^2.12.0",
"amazon-date-parser": "^0.1.5",
"date-and-time": "^0.6.3",
"dialogflow": "^0.6.0",
"express": "^4.17.1",
"firebase-admin": "^6.5.1",
"firebase-functions": "^3.9.0",
"moment-timezone": "^0.5.31",
"node-pre-gyp": "^0.15.0",
"promise": "^8.1.0",
"request": "^2.88.2"
},
"engines": {
"node": "10"
},
"devDependencies": {
"firebase-functions-test": "^0.2.1"
},
"private": true,
"version": "1.0.0",
"main": "index.js",
"author": "",
"license": "ISC"
}

我在谷歌上测试我的操作时出现以下错误

TypeError: Cannot read property 'stack' of undefined
at standard.then.catch (/workspace/node_modules/actions-on-google/dist/framework/express.js:37:32)
at process._tickCallback (internal/process/next_tick.js:68:7)

错误不在我的index.js中。错误在express.js.的谷歌npm模块库上的操作中

我删除了我的节点模块,重新安装并重新生成代码。仍然会出现同样的错误。

请帮我解决这个问题。

如果您在Firebase中使用云函数,我根本不会想到会调用该代码。

我怀疑包括";express";依赖项中的包引入了express的外部版本,这混淆了google库上的操作,该库单独定义了express类型。a-o-g库将此库用于那些直接使用express来设置路由的人,如果您使用云函数,则不必使用此库。

我建议删除该包,并确保它不在您的节点模块中。

最新更新