ABC
ABC

Reputation: 832

How to fix the Cannot find module mp3 file or its corresponding type declarations

enter image description here

How to fix the error Cannot find module './audio/audio1.mp3' or its corresponding type declarations. also already use the require('./audio/audio1.mp3') and also getting an error.

Upvotes: 1

Views: 4223

Answers (1)

Naren Hemnani
Naren Hemnani

Reputation: 61

Inside the src/react-app-env.d.ts add this:

/// <reference types="react-scripts" />
    declare module '*.mp3'; // '*.wav' if you're using wav format

Now you can use it like this:

import audio1 from './audio/audio.mp3';

const myAudio = new Audio(audio1);

Upvotes: 6

Related Questions