Home > Software engineering >  When i am trying to import SVG image getting this error "Failed to compile " in Toolbar
When i am trying to import SVG image getting this error "Failed to compile " in Toolbar

Time:09-22

Failed to compile ./src/layout/Navbar.js Module not found: Can't resolve './assets/logo.svg' in 'D:\react\03\src\layout' This error occurred during the build time and cannot be dismissed.

Here is my code

import React from 'react';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Logo from './assets/logo.svg';
const Navbar = () => {
    return (
        <AppBar position="static">
            <Toolbar>
                <div>
                    <img src={Logo} alt="logo" />
                </div>
            </Toolbar>
        </AppBar>
    );
};
export default Navbar;

CodePudding user response:

Your path is not correct.

Remplace

import Logo from './assets/logo.svg';

by

import Logo from '../assets/logo.svg';

  • Related