Node.js GCP部署时未上载本地.js文件
我遵循了部署了三个功能的。所以目前我已经成功部署了三个云功能 我在index.js文件中编写了第四个函数:Node.js GCP部署时未上载本地.js文件,node.js,google-cloud-platform,google-cloud-functions,Node.js,Google Cloud Platform,Google Cloud Functions,我遵循了部署了三个功能的。所以目前我已经成功部署了三个云功能 我在index.js文件中编写了第四个函数: const userInput = require('user-input.js'); // more code in the middle from the tutorial exports.compareUserToDetectedText = async (event) => { input = userInput.getUserInput(`${originalFil
const userInput = require('user-input.js');
// more code in the middle from the tutorial
exports.compareUserToDetectedText = async (event) => {
input = userInput.getUserInput(`${originalFilename}.txt`);
console.log(input);
}
// Get a reference to the Cloud Storage component
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
exports.getUserInput = (filename) => {
const bucket = storage.bucket('my_bucket_name');
const remoteFile = bucket.file(filename);
}
并在与我的index.js文件相同的目录中创建了一个新文件user-input.js:
const userInput = require('user-input.js');
// more code in the middle from the tutorial
exports.compareUserToDetectedText = async (event) => {
input = userInput.getUserInput(`${originalFilename}.txt`);
console.log(input);
}
// Get a reference to the Cloud Storage component
const {Storage} = require('@google-cloud/storage');
const storage = new Storage();
exports.getUserInput = (filename) => {
const bucket = storage.bucket('my_bucket_name');
const remoteFile = bucket.file(filename);
}
当我尝试部署此功能时:
gcloud functions deploy ocr-compare \
--runtime nodejs10 \
--trigger-bucket [my trigger bucket] \
--entry-point compareUserToDetectedText \
--set-env-vars "^:^GCP_PROJECT=[project ID],RESULT_BUCKET=[my result bucket]"
我在日志中发现此错误:
"Function 'compareUserToDetectedText' is not defined in the provided module."
Did you specify the correct target function to execute?
Could not load the function, shutting down.
当我启动时,该函数的源代码将更新。为什么没有为这个新的compareUserToDetectedText函数上载源代码?您能提供整个index.js文件吗?“compareUserToDetectedText”似乎设置不正确。由于您包含user-input.js,我认为您应该首先部署getUserInput,尝试部署getUserInput,然后部署compareUserToDetectedText。