javascript - How to fix the Cannot find module mp3 file or its corresponding type declarations - Stack Overflow

How to fix the error Cannot find module '.audioaudio1.mp3' or its corresponding type declara

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.

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.

Share Improve this question asked Feb 21, 2022 at 11:05 ABCABC 8326 gold badges20 silver badges45 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745324987a4622614.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信