capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
242 stars 83 forks source link

[help wanted] I am importing the Cannot use import statement outside a module issue #139

Open xiningli opened 1 year ago

xiningli commented 1 year ago

Could someone just give me some help? I am trying to import the @capacitor-community/fcm in my NEXTJS project. And I am facing this issue.

There is no issue for me to import { PushNotifications } from '@capacitor/push-notifications';

But when I am trying to import the import { FCM } from "@capacitor-community/fcm";

I am seeing the following issue.

info - Collecting page data ./[mypath]/node_modules/@capacitor-community/fcm/dist/esm/index.js:1 import { registerPlugin } from "@capacitor/core"; ^^^^^^

SyntaxError: Cannot use import statement outside a module

Saqib92 commented 1 year ago

Could someone just give me some help? I am trying to import the @capacitor-community/fcm in my NEXTJS project. And I am facing this issue.

There is no issue for me to import { PushNotifications } from '@capacitor/push-notifications';

But when I am trying to import the import { FCM } from "@capacitor-community/fcm";

I am seeing the following issue.

info - Collecting page data ./[mypath]/node_modules/@capacitor-community/fcm/dist/esm/index.js:1 import { registerPlugin } from "@capacitor/core"; ^^^^^^

SyntaxError: Cannot use import statement outside a module

facing exactly the same issue.

QualitasGit commented 1 year ago

Same issue here. Anyone found a solution?

lohnsonok commented 1 year ago

Same issue for me too

AlexCyphus commented 1 year ago

Hey! If you're using NextJS - you can fix it by transpiling the package in your next config file. You can find more info here: https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages