I cannot get my eas build of my app to work because it can’t find the audio file I’m importing on my home screen. The specific eas command I’m running is eas build --platform ios --profile preview
. The error happens in the bundle javascript step. Note this error does not happen when I run a development build of the app in the simulator (npx expo run:ios -d
Unable to resolve module ../../assets/audio/meditation_10_min.mp3 from /Users/expo/workingdir/build/app/(tabs)/index.jsx:
const track = require("../../assets/audio/meditation_10_min.mp3");
const player = useAudioPlayer(track);
What I’ve tried
- Not using
require
and just importing the asset like normal. - Using
expo-asset
like so:
const [assets, error] = useAssets([
require("../../assets/audio/meditation_10_min.mp3"),
]);
const player = useAudioPlayer(assets[0]);
It doesn’t work, assets
is undefined. I’m not sure how this API is supposed to be used. It feels like it’s missing some loading
boolean so I don’t pass undefined
to my useAudioPlayer
call.
- Embedding the asset directly in the app at build time with expo-asset
//app.json
"plugins": [
"expo-audio",
[
"expo-asset",
{
"assets": ["./assets/audio/meditation_10_min.mp3"]
}
]
],
// usage in component
import { useAudioPlayer } from "expo-audio";
const player = useAudioPlayer("meditation_10_min.mp3");