I've just made my first decent Google Cloud Function and now I'd like to refactor it into libraries.
Example, I've got my Cloud Function and I'd like to require a library I've created, not something installed from NPM.
How do I deploy these libraries to Google Cloud Functions?
If I understand your question correctly, you want to create a module out of your common.js
file.
If that is the case, in common.js
, export it like so:
export default function(){
// Here is your common code
}
and then just import it into your function file:
import common from './common.js';
Try using --include-node-modules
flag to include node_modules
folder with deployed sources.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.