In my NodeJS application I have few common code that could be used by many other Cloud Functions in GCP. But I don't know how can I share these code among multiple apps to reduce code redundancy.
I thought of keeping these files in GCS and use that file location in NodeJS but I am sure it won't support this way as I may need to download this file before using it.
So, is there any better way to accomplish my idea?
What is the best way to use local module in NodeJS Cloud Functions?
376 Views Asked by shary.sharath At
1
There are 1 best solutions below
Related Questions in NODE.JS
- How to solve CERT_UNTRUSTED error in nodemailer
- Run a loop over a callback, node js
- Implementing prerender.io middleware in sails.js
- Token based authorization in nodejs/ExpressJs and Angular(Single Page Application)
- formatting path string in javascript
- One to One screensharing using WEBRTC
- Create polygon from grid (for collisions)
- Strange npm behavior when installing packages like grunt
- Convert JSON.gz to JSON in node js
- "Your npm version is outdated." but it's not. While install yo
- Why put methods on the prototype of a class instead of declaring them in the constructor?
- Node JS Async Response
- mongoose get property from nested schema after `group`
- Cannot Receive Incoming call on Twilio android Client
- How can I change a specific line in a file with node js?
Related Questions in GOOGLE-CLOUD-FUNCTIONS
- Deploying multiple Google Cloud Functions from same repo
- Intermittent authentication errors in Cloud Functions
- Functions debugging in VS Code
- Firebase cloud function not triggering when deleting in transaction
- Firebase functions onCreate() onDelete() path specificity
- How to trigger Cloud Function only when child is added to the database?
- Firebase Cloud Functions called multiple times
- 'firebase serve...'. Web service URL returns "Function X in location us-central1 in project Y does not exist"
- Firebase HTTP function accessing userID?
- Google Cloud Function Not Terminating Past Max Function Duration
- GET UID from firebase cloud functions
- Pointing a subdomain to Firebase functions
- Actions on Google TDD or testing environment
- Can't add 2 Cloud Functions?
- ReferenceError: firebase is not defined in cloud functions
Related Questions in LOCAL-NODE-MODULES
- How to put webPack config file in to node modules?
- Do we need to install all plugins from scratch in Gatsby?
- Can't succeed in unexcluding node_modules in WebStorm Node React
- In angular, the size of my main.js file is 20mb and vendor.js file is 7mb, what could be the issue and how can I optimize my build?
- Using npm on a machine without internet access, but with lots of modules in mutiple node_modules directorties
- electron install error : Generated checksum for "electron-v2.0.2-win32-x64.zip" did not match expected checksum
- Visual Studio Code ionic "node_modules" unavailable
- Why Angular 2+ need to be pre-installed before creating project since it has node_modules installed itself?
- When I build docker image, i want to prevent installing node_modules in my local directory
- using a locally edited npm package
- How to update local node_module dependency and reload in another project?
- npm-cron issue with task.stop() from inside another function
- What is the best way to use local module in NodeJS Cloud Functions?
- How to allow a custom local node_module to navigate project file system?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You have several way to solve that.
At deployment time (with your CI/CD, on Cloud Build for instance) you can copy the common dependencies in the Cloud Functions code base and then deploy it. It's (it was) a common and usual way to share common code with Cloud Functions.
But, a more recent way is to use Artifact Registry to store your NodeJS modules. Then, in your cloud functions dependencies, reference that module in Artifact Registry to let Cloud Functions downloading it.
It's a better solution because you use standard code packaging and dependencies, it's private to your project (except if you open your registry publicly) and you haven't hack to do.
--
You can also switch to Cloud Run, where you control your container creation and download the file that you want. It's not Cloud Functions, but it's very similar (and it's my personal preference)