TypeError: Cannot read property 'pubsub' of undefined
TypeError: Cannot read property 'pubsub' of undefined
我想使用 firebase 函数做一个 cron 作业并遵循文档 here
这是我写的代码
import functions from "firebase-functions";
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
return null;
});
但是当我想使用 npm run deploy
部署它时,我得到了这个
TypeError: Cannot read property 'pubsub' of undefined
at Object.<anonymous> (C:\Users\Fajar Alnito\Documents\work\axie-boxy\functions\lib\index.js:106:51)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at loadModule (C:\Users\Fajar Alnito\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\runtimes\node\triggerParser.js:10:16)
at C:\Users\Fajar Alnito\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\runtimes\node\triggerParser.js:34:21
at Object.<anonymous> (C:\Users\Fajar Alnito\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\runtimes\node\triggerParser.js:72:3)
但是打字稿在代码编辑器上没有给出任何错误
我已经更正了您导入模块的代码。这对我有用:
import * as functions from "firebase-functions";
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
return null;
});
我想使用 firebase 函数做一个 cron 作业并遵循文档 here
这是我写的代码
import functions from "firebase-functions";
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
return null;
});
但是当我想使用 npm run deploy
部署它时,我得到了这个
TypeError: Cannot read property 'pubsub' of undefined
at Object.<anonymous> (C:\Users\Fajar Alnito\Documents\work\axie-boxy\functions\lib\index.js:106:51)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at loadModule (C:\Users\Fajar Alnito\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\runtimes\node\triggerParser.js:10:16)
at C:\Users\Fajar Alnito\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\runtimes\node\triggerParser.js:34:21
at Object.<anonymous> (C:\Users\Fajar Alnito\AppData\Roaming\npm\node_modules\firebase-tools\lib\deploy\functions\runtimes\node\triggerParser.js:72:3)
但是打字稿在代码编辑器上没有给出任何错误
我已经更正了您导入模块的代码。这对我有用:
import * as functions from "firebase-functions";
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
return null;
});