Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import images in react, Module Not Found

Tags:

reactjs

my react app cannot find my image file. I have tried multiple ways of importing. I am importing this in my App.js

import logo from "./images/companyLogo.png"

<img src={logo} />
<img src={require("./images/companyLogo.png")} />

I even saw a way by putting the images file in the public folder and import it like following: (don't know why this worked for some people)

<img src="images/companyLogo.png" />

I have checked my directory it looks fine.

enter image description here

enter image description here Please help T_T

like image 303
Haiquan Zheng Avatar asked May 13 '26 20:05

Haiquan Zheng


1 Answers

You need to have a Webpack loader in your webpack config to import images or other such files.

Webpack File Loader

like image 63
Dan Philip Avatar answered May 15 '26 11:05

Dan Philip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!