I'm following This tutorial, trying to deploy some functions to Firebase, and I can successfully deploy them to my project id. When accessing the following function on the provided URL, I get the error: could not handle the request
// The Cloud Functions for Firebase SDK to create Cloud Functions and setup
triggers.
const functions = require('firebase-functions');
// The Firebase Admin SDK to access the Firebase Realtime Database.
const admin = require ('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.date = functions.https.onRequest((req, res) => {
let format = req.query.format;
const date = moment().format();
res.status(200).json({ date: date});
})
My Firebase console logs this on execution:
ReferenceError: moment is not defined
at exports.date.functions.https.onRequest (/user_code/index.js:10:24)
at cloudFunction (/user_code/node_modules/firebase-
functions/lib/providers/https.js:26:41)
at /var/tmp/worker/worker.js:635:7
at /var/tmp/worker/worker.js:619:9
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
My package.json in my functions folder has "moment": "^2.19.1" under dependencies.
What am I doing wrong? How do I define moment?