You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While deploying a TypeScript Firebase Cloud Function with the command:
firebase deploy --only functions:mapsRegionSearch
I'm seeing the error:
Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module
I've isolated the issue / error to the specific cloud function shown below where I am using "@googlemaps/region-lookup"; all the other Cloud Functions in the project deploy without error when this Cloud Function is removed from the set.
Any insight on how to work around this error? I've followed the [documentation](https://developers.google.com/maps/documentation/javascript/dds-boundaries/region-lookup), but I'm stuck.
Node version 16.20.0
Firebase CLI version 12.2.1
import * as functions from "firebase-functions";
import * as admin from "firebase-admin";
import { searchRegion, SearchRegionRequestData, SearchRegionResponse } from "@googlemaps/region-lookup";
export const mapsRegionSearch = functions.firestore
.document("responses/{responseId}")
.onCreate((change, context) => {
if (change.data().coordinate) {
return regionSearch(change, context);
} else {
console.log("this response did not have any coordinates attached");
return;
}
});
async function regionSearch(change: any, context: any) {
// Headers
const headers: any = {
"X-Goog-Api-Key": "XXXXX",
};
const data: SearchRegionRequestData = {
search_values: [
{
latlng: change.data().coordinate,
place_type: "administrative_area_level_1",
},
],
};
const response: SearchRegionResponse = await searchRegion({ headers, data });
console.log("region search returned this place id or error: ", response);
if (response) {
const db = admin.firestore();
// do stuff
}
}
The text was updated successfully, but these errors were encountered:
I'm having the same issue
All my code is working properly and the module bundling works for every other package, its a nestJS application and i'm getting this error on compilation
`C:\Users\Bruno\Desktop\work\project\node_modules@googlemaps\region-lookup\dist\index.esm.js:34
import axios from "axios";
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Function.Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18)
at Object. (C:\Users\Bruno\Desktop\work\project\src\maps\maps.service.ts:13:1)
at Module._compile (node:internal/modules/cjs/loader:1254:14)`
While deploying a TypeScript Firebase Cloud Function with the command:
firebase deploy --only functions:mapsRegionSearch
I'm seeing the error:
Error: Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Cannot use import statement outside a module
I've isolated the issue / error to the specific cloud function shown below where I am using "@googlemaps/region-lookup"; all the other Cloud Functions in the project deploy without error when this Cloud Function is removed from the set.
Any insight on how to work around this error? I've followed the
[documentation](https://developers.google.com/maps/documentation/javascript/dds-boundaries/region-lookup)
, but I'm stuck.Node version 16.20.0
Firebase CLI version 12.2.1
The text was updated successfully, but these errors were encountered: