native-audio icon indicating copy to clipboard operation
native-audio copied to clipboard

Error with plugin initialization and import: capacitorExports is not defined

Open sethlangel opened this issue 1 year ago • 7 comments

Describe the bug A clear and concise description of what the bug is.

Initialization of plugin and importing NativeAudio throws an error

ReferenceError: capacitorExports is not defined

To Reproduce Steps to reproduce the behavior:

  1. Import NativeAudio as described in the docs??

Expected behavior Plugin and methods get imported, methods able to be used to load the audio.

-Web, iOS, and Android

Additional context I removed the NativeAudio.preload code and it still crashed. I removed the import and the error went away. Using NextJS 12.

sethlangel avatar Oct 31 '23 03:10 sethlangel

Having the same issue

formicagreen avatar Nov 07 '23 14:11 formicagreen

same issues with next js build

liho00 avatar Dec 24 '23 08:12 liho00

Same issues with next js build

bennieforss avatar Jan 02 '24 19:01 bennieforss

here as well. any ideas for a workaround?

hesslau avatar Feb 07 '24 17:02 hesslau

In my case this was caused by an issue with the ESM module version. If you explicitly load the commonJS version, it seems to be working fine. You can do this in the following way:

import { NativeAudio } from '@capgo/native-audio/dist/plugin.cjs';

Note that I'm using the Capgo fork, but might work with the capacitor-community version as well

jormaj avatar Apr 24 '24 11:04 jormaj

Having the same issue,

JACKZGGG avatar Jun 27 '24 03:06 JACKZGGG

can you provide a sample app? I can't reproduce

jcesarmobile avatar Jun 28 '24 16:06 jcesarmobile