question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

'capacitorExports is not defined' error during bundling

See original GitHub issue

First of all, thank you for your work on the plugin @pwespi, I believe it will help us greatly when we make it work 😃

Here is the issue:

Describe the bug Our project’s web assets (webpack) build is failing if the following import { BleClient } from '@capacitor-community/bluetooth-le'; defined somewhere in the code.

The error is the following:

ReferenceError: capacitorExports is not defined at Object.<anonymous> (/projectDir/node_modules/@capacitor-community/bluetooth-le/dist/plugin.js:403:7)

The contents of the plugin.js file at line 403 (with some additional lines above, for context):

   ...

   exports.BleClient = BleClient;
    exports.BluetoothLe = BluetoothLe;
    exports.BluetoothLeWeb = BluetoothLeWeb;
    exports.dataViewToHexString = dataViewToHexString;
    exports.dataViewToNumbers = dataViewToNumbers;
    exports.dataViewToText = dataViewToText;
    exports.hexStringToDataView = hexStringToDataView;
    exports.mapToObject = mapToObject;
    exports.numberToUUID = numberToUUID;
    exports.numbersToDataView = numbersToDataView;
    exports.textToDataView = textToDataView;
    exports.webUUIDToString = webUUIDToString;

 Object.defineProperty(exports, '__esModule', { value: true });

 return exports;

}({}, capacitorExports)); // <-- line 403 from the error

We are using the NextJS’s next build command to run build, but I guess it doesn’t matter which bundler is used.

To Reproduce Steps to reproduce the behavior:

  1. install bluetooth-le capacitor plugin and import it somewhere.
  2. Run the build to bundle your app.

Expected behavior The build is passing without errors from the plugin.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
pwespicommented, Jan 9, 2021

Closed in #14 and released as 0.1.1.

(no need to change the import, just use import { BleClient } from "@capacitor-community/bluetooth-le";)

1reaction
muesliriegercommented, Jan 11, 2021

Thanks a lot, everything’s working smoothly now! 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript ReferenceError: exports is not defined
Are you sure you did not type exports with an s at the end instead of export ? That would explain the error...
Read more >
capacitorExports is not defined" while running jest tests in a ...
I got this horrible "ReferenceError: capacitorExports is not defined" error while running the tests in my Ionic/Angular/Capacitor project ...
Read more >
typeerror is not a function node js js How to resolve "uncaught ...
"ReferenceError: capacitorExports is not defined" while running jest tests ... Jest will not The error message "jQuery is not defined" clearly says that...
Read more >
Renovate Bot Package Diff
+ * **cli:** do not error if webDir is missing when adding platforms ... You can control the set of applied configuration files...
Read more >
Untitled
Set up automap with logic pro x, Rush 24 laptop, Jaysinh shankarrao mohite-patil ... Dil e abad hum tv part 12, Beecake this...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found