title: Google cloud function deploy fails
body: <p>when i am running the gcloud functions deploy gcp_test --trigger-resource xxx-test-123 --trigger-event google.storage.object.finalize i am getting syntax error .</p>
  
  <blockquote>
    <p>ERROR: (gcloud.functions.deploy) OperationError: code=3,
    message=Function load error: Code in file index.js can't be loaded. Is
    there a syntax error in your code? Detailed stack trace:
    /user_code/index.js:1 (function (exports, require, module, __filename,
    __dirname) { # index.js
                                                                  ^</p>
    
    <p>SyntaxError: Invalid or unexpected token
        at createScript (vm.js:56:10)
        at Object.runInThisContext (vm.js:97:10)
        at Module._compile (module.js:549:28)
        at Object.Module._extensions..js (module.js:586:10)
        at Module.load (module.js:494:32)
        at tryModuleLoad (module.js:453:12)
        at Function.Module._load (module.js:445:3)
        at Module.require (module.js:504:17)
        at require (internal/module.js:20:19)
        at getUserFunction (/var/tmp/worker/worker.js:388:24)</p>
  </blockquote>
  
  <p>I am not sure why this error is appearing. I have installed npm module for @google-cloud/storage . Any help is appreciated .This function is suppose to enable stackdriver logging .
  reference: <a href="https://medium.com/google-cloud/encrypting-stackdriver-logging-sinks-using-customer-managed-encryption-keys-for-gcs-ccd0b59f0a3" rel="nofollow noreferrer">https://medium.com/google-cloud/encrypting-stackdriver-logging-sinks-using-customer-managed-encryption-keys-for-gcs-ccd0b59f0a3</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>    # index.js
              'use strict';
              const Buffer = require('safe-buffer').Buffer;
              // Imports the Google Cloud client library
              const Storage = require('@google-cloud/storage');
              // Creates a client
              const storage = new Storage();
              exports.moveFileToEncryptedStorage = (event, callback) =&gt; {
                const file = event.data;
                console.log(  Event ${event.eventId});
                console.log(  Event Type: ${event.eventType});
                console.log(  Bucket: ${file.bucket});
                console.log(  File: ${file.name});
                console.log(  Metageneration: ${file.metageneration});
                console.log(  Created: ${file.timeCreated});
                console.log(  Updated: ${file.updated});
              const newBucket = "xxx-test-123";
              const newBucketAndFileName = "gs://"+newBucket+"/"+file.name;
              console.log("Moving to..."+newBucketAndFileName);
              return storage
                    .bucket(file.bucket)
                    .file(file.name)
                    .move(newBucketAndFileName)
                    .then(() =&gt; {
              
                      console.log("content has been moved to "+newBucketAndFileName);
              })
                    .catch((err) =&gt; {
                      console.error("ERROR:"+err);
                    });
              }</code></pre>
  </div>
  </div>
  </p>