Haiquan Zheng
Haiquan Zheng

Reputation: 51

Cannot import images in react, Module Not Found

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

Upvotes: 3

Views: 3902

Answers (1)

Dan Philip Bejoy
Dan Philip Bejoy

Reputation: 4381

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

Webpack File Loader

Upvotes: 1

Related Questions