title: Google Cloud Function - Error: Cannot find module google-cloud/bigquery
body: <p>I am working to create a cloud function that moves avro files from GCS to BigQuery, anytime a new file lands in GCS. I am using the cloud function ui in GCP. I have 512 MB for memory allocated. Trigger is Google Storage. Event Type if Finalize/Create. Source Code is Inline Editor. </p>
  
  <p>Below is my code. I can successfully deploy, but I am receiving the below error post deployment, and nothing moves to BigQuery. </p>
  
  <p>Additionally, I am attempting to move avro files from a folder WITHIN a bucket, so I am not pulling directly from the top parent bucket. That is the purpose of the below code, as I attempt to get into the folder, which is called "example_spend/"</p>
  
  <p>error: Cannot find module google-cloud/bigquery</p>
  
  <pre><code>'use strict';
  
  exports.createExampleTableFromFile = function(event, callback) {
  const file = event.data;
  if (file.resourceState === 'exists' &amp;&amp; file.name &amp;&amp; 
      file.name.indexOf('example_spend/') !== -1) {
  
  console.log('Processing file: ' + event.data.name);
  
  
  const BigQuery = require('@google-cloud/bigquery');
  const Storage = require('@google-cloud/storage');
  const assert = require('assert');
  
  
   const filename = event.data.name;
   const bucketName = event.data.bucket;
  
  
  const projectId = "gcp-pilot-192921";
  const datasetId = "example_etl";
  const tableId = filename.slice(0,filename.indexOf(".")).toLowerCase();  
  
  
  const bigquery = new BigQuery({
    projectId: projectId,
  });
  
  const storage = Storage({
    projectId: projectId
  });  
  
  
  const metadata = {
    sourceFormat: 'AVRO', 
    autodetect: true, 
    writeDisposition: 'WRITE_TRUNCATE'
  };
  
  bigquery
    .dataset(datasetId)
    .table(tableId)
    .load(storage.bucket(bucketName).file(filename), metadata)
    .then(results =&gt; {
      const job = results[0];
  
  
      assert.equal(job.status.state, 'DONE');
      console.log(`Job ${job.id} to load table ${tableId} completed.`);  
  
  
      const errors = job.status.errors;
      if (errors &amp;&amp; errors.length &gt; 0) {
        throw errors;
      }
  
    })
    .catch(err =&gt; {
      console.error('Error during load job:', err);
    });
  
  callback();
  }};
  </code></pre>