This question is similar, but did not help.
We see this error when using ES6 on Google Cloud Functions:
Deployment failure: Build failed: /workspace/index.js:4 import { get } from 'axios'; ^ SyntaxError: Unexpected token { at new Script (vm.js:83:7) atcheckScriptSyntax (internal/bootstrap/node.js:620:5) at startup (internal/bootstrap/node.js:280:11) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3); Error ID: d984e68f
How can we use ES6 syntax with Google Cloud Function?
Code:
/**
 * Required Modules
 */
import { get } from 'axios';
import { parseString } from 'xml2js';
/**
 * Responds to any HTTP request.
 *
 * @param {!express:Request} req HTTP request context.
 * @param {!express:Response} res HTTP response context.
 */
export async function run(req, res) {
  // Set API end point.
  let apiURL = 'https://www.w3schools.com/xml/note.xml';
  // Wrap API parameters in convenient object.
  let apiData = {
    PARAM_1: 'PARAM_DATA',
    PARAM_2: 'PARAM_DATA',
  };
  // Invoke API.
  get(apiURL,
    JSON.stringify(apiData)
  )
  .then((response) => {
    //res.status(200).send(response.data);
    let xmlData = response.data;
    parseString(xmlData, (err, result) => {
      if (err) {
        console.error(err);
   
 res.status(500).end();
    return;
  }
  res.status(200).send(result);
});
}, (error) => { res.status(500).send(response.data); console.log(error); }); }