AlwaysLoveme / capacitor-plugin-safe-area

capacitor plugin to get safeArea info on Android and IOS, support Capacitor6
MIT License
66 stars 14 forks source link

ReferenceError: exports is not defined in ES module scope #14

Closed gommzystudio closed 1 year ago

gommzystudio commented 1 year ago

Hey, thanks for updating to capacitor v5!

When I build my capacitor app, I get this error:

> next build && next export

info  - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/basic-features/eslint#disabling-rules
- info Linting and checking validity of types  
- info Creating an optimized production build  
- info Compiled successfully
- info Collecting page data ..ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/***/node_modules/capacitor-plugin-safe-area/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///***/node_modules/capacitor-plugin-safe-area/dist/plugin.cjs.js:3:23
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

> Build error occurred
Error: Failed to collect page data for /
    at /***/node_modules/next/dist/build/utils.js:1152:15 {
  type: 'Error'
}
- info Collecting page data .
Process finished with exit code 1

My package.json:

{
  "name": "***",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "static": "next build && next export",
    "sync": "npm run static && npx cap sync",
    "ios": "npx cap open ios",
    "android": "npx cap open android"
  },
  "dependencies": {
    "@capacitor/android": "next",
    "@capacitor/browser": "next",
    "@capacitor/haptics": "next",
    "@capacitor/ios": "next",
    "@capacitor/keyboard": "next",
    "@types/node": "^20.2.1",
    "@types/react": "^18.2.6",
    "@types/react-dom": "^18.2.4",
    "bootstrap": "^5.2.3",
    "bootstrap-icons": "^1.10.5",
    "capacitor-plugin-safe-area": "^2.0.0",
    "eslint": "^8.40.0",
    "eslint-config-next": "^13.4.3",
    "framer-motion": "^10.12.12",
    "next": "^13.4.3",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "typescript": "^5.0.4",
    "uuid": "^9.0.0"
  },
  "devDependencies": {
    "@capacitor/cli": "next",
    "@types/uuid": "^9.0.1"
  }
}

Thanks!

gommzystudio commented 1 year ago

"capacitor-plugin-safe-area": "^2.0.0", -> capacitor-plugin-safe-area": "^2.0.1",

I tried both version

AlwaysLoveme commented 1 year ago

"capacitor-plugin-safe-area": "^2.0.0", -> capacitor-plugin-safe-area": "^2.0.1",

I tried both version

Ok,i will fix this in a few days

MaritFischer commented 1 year ago

Running into the same issue as well.

AlwaysLoveme commented 1 year ago

Running into the same issue as well.

fixed in latest version