Firebase error: "Error parsing triggers: Cannot find module './clone.js'"
Firebase error: "Error parsing triggers: Cannot find module './clone.js'"
当我 运行 firebase deploy --only functions
时,我收到此错误消息:
Error parsing triggers: Cannot find module './clone.js'
这是我的代码,复制自 documentation:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
const bucketName = 'myapp.appspot.com';
const filename = './hola_mundo.wav';
admin.initializeApp();
exports.Storage = functions.firestore.document('Test_Value').onUpdate((change, context) => {
storage.bucket(bucketName).upload(filename, {
gzip: true,
metadata: {
cacheControl: 'no-cache'
}
})
.then(() => {
console.log(`${filename} uploaded to ${bucketname}`);
})
.catch(err => {
console.error(err);
});
});
clone.js
是这个npm module吗?
我将常量移到函数中,错误消失了:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.Storage = functions.firestore.document('Test_Value').onUpdate((change, context) => {
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
const bucketName = 'myapp.appspot.com';
const filename = './hola_mundo.wav';
storage.bucket(bucketName).upload(filename, {
gzip: true,
metadata: {
cacheControl: 'no-cache'
}
})
.then(() => {
console.log(`${filename} uploaded to ${bucketname}`);
})
.catch(err => {
console.error(err);
});
});
当我 运行 firebase deploy --only functions
时,我收到此错误消息:
Error parsing triggers: Cannot find module './clone.js'
这是我的代码,复制自 documentation:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
const bucketName = 'myapp.appspot.com';
const filename = './hola_mundo.wav';
admin.initializeApp();
exports.Storage = functions.firestore.document('Test_Value').onUpdate((change, context) => {
storage.bucket(bucketName).upload(filename, {
gzip: true,
metadata: {
cacheControl: 'no-cache'
}
})
.then(() => {
console.log(`${filename} uploaded to ${bucketname}`);
})
.catch(err => {
console.error(err);
});
});
clone.js
是这个npm module吗?
我将常量移到函数中,错误消失了:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.Storage = functions.firestore.document('Test_Value').onUpdate((change, context) => {
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
const bucketName = 'myapp.appspot.com';
const filename = './hola_mundo.wav';
storage.bucket(bucketName).upload(filename, {
gzip: true,
metadata: {
cacheControl: 'no-cache'
}
})
.then(() => {
console.log(`${filename} uploaded to ${bucketname}`);
})
.catch(err => {
console.error(err);
});
});