fcm icon indicating copy to clipboard operation
fcm copied to clipboard

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

Open xiningli opened this issue 2 years ago • 4 comments

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

xiningli avatar Dec 20 '22 07:12 xiningli

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.

Saqib92 avatar Dec 30 '22 12:12 Saqib92

Same issue here. Anyone found a solution?

QualitasGit avatar Mar 09 '23 11:03 QualitasGit

Same issue for me too

lohnsonok avatar Mar 29 '23 08:03 lohnsonok

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

AlexCyphus avatar Jul 06 '23 12:07 AlexCyphus