How to save the image and where to save it for HTML

I am trying to add an image but when I reference the image I get ModuleNotFoundError
Could not find module in path: ‘./elephant.jpg’ relative to ‘/index.html’

This is my code so far

<html>

<head>
	<title>Parcel Sandbox</title>
	<meta charset="UTF-8" />
</head>

<body>
	<div id="app"></div>

	<script src="src/index.js">
	</script>
	<img src="elephant.jpg"
	alt="A cute elephant!"/>
</body>

</html>


This is the error I'm getting.

×
ModuleNotFoundError
Could not find module in path: './elephant.jpg' relative to '/index.html'


**Challenge:**  Add Images to Your Website

**Link to the challenge:**
https://www.freecodecamp.org/learn/responsive-web-design/basic-html-and-html5/add-images-to-your-website

OK, you have a link to a challenge, but you seem to be asking about a local site…

WIth regards to the image, you should just need to provide a valid path. If the image is in the same folder as the index.html, I would expect the url to be something like:

<img src="./elephant.jpg" alt="A cute elephant!"/>

Hi Kevin!

Thank you so much for your response!
I changed the code to <img src="./elephant.jpg" alt="A cute elephant!"/> but I’m still getting the same error ModuleNotFoundError
Could not find module in path: ‘./src/elephant.jpg’ relative to ‘/index.html’

I saved my image from a google search and saved the image as elephant.jpg in the pictures folder underneath “This PC”. It’s in the saved pictures folder. Is that the same place as the html?

What is the folder where you have your index.html file?

Maybe I’m confused. Where are you trying to do this? Are you doing it in the FCC editor? That won’t work. It can’t “see” what’s on your computer. My advice was for if you were building the web site on your local computer.

I’m using codesandbox, vanilla. I don’t think I’ve saved the html and I’m not sure how to do that. How would I save my html?

I haven’t done that before, but you’d have to figure out how to upload files to the IDE. It needs to be in that folder in codesandbox.

#lmgtfy

Thanks! Checking that out now!

Okay, I did that but I’m still getting that error.

The image is located in the elephant.jpg section

Wait, it worked! Thank you again for the help!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.