Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Gets "Module not found: Error: Can't resolve" when trying to import logo in React

Im trying to make a navbar in React app. Ive done a component called "Navbar" with the code below, but the logo dont show up on the website. Get "Module not found: Error: Can’t resolve".
If I import the logo in App.js file, it works. But not in Navbar.js. Why?

import React from 'react';
import Logo from './assets/images/react-logo-small.png'

function Navbar() {
    return(
        <div className='nav_container'>
            <nav className='navbar'>
                <img src={Logo} alt="Logo"/>
                <h3 className='nav--logo_text'>ReactFacts</h3>
                <h4 className='nav--title'>React Course - Project 1</h4>
            </nav>
        </div>
    )
}

export default Navbar;

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Are App.js and Navbar.js in the same folder?

If not, then the problem is the path to the image, and you should change it so that it shows how you can get to the image from the folder where Navbar.js is stored.

Helpful tip:

./ means to start from the current folder

../ means to go up one folder and start from there

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading