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:
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.