Google cloud + serverless - RequiringAPIs



I’m trying to import the Google Vision API inside my Serverless handler.js; but whenever I try to use the require('@google-cloud/vision') I get a syntax error - see error below. I pasted my stub code below for reference.

Error Message:
{"ResourceType":"cloudfunctions.v1beta2.function","ResourceErrorCode":"400","ResourceErrorMessage":"Function load error: Code in file handler.js can't be loaded.\nIs there a syntax error in your code?\nDetailed stack trace: TypeError: require(...) is not a function\n at Object.<anonymous> (/user_code/handler.js:6:47)\n at Module._compile (module.js:570:32)\n at Object.Module._extensions..js (module.js:579:10)\n at Module.load (module.js:487:32)\n at tryModuleLoad (module.js:446:12)\n at Function.Module._load (module.js:438:3)\n at Module.require (module.js:497:17)\n at require (internal/module.js:20:19)\n at getUserFunction (/var/tmp/worker/worker.js:373:24)\n at loadUserCode (/var/tmp/worker/worker.js:429:18)"}

My code:

const vision = require('@google-cloud/vision')()

module.exports.parseImage = (req,res) => {

module.exports.helloWorld = (req,res) => {
  res.status(200).send('HELLO WORLD FROM SERVERLESS')

I was wondering if anyone could help me figure out why my code is not compiling correctly.