title: Unable to import image in Reactjs returning error Module not found: Can't resolve
body: <p>I have the following component located in "projectfolder/src/pages/Home.js":-</p>
  
  <pre><code>import React from "react";
  import MenuButton from "../components/Home/MenuButton";
  import menuicon from "images/menuicon.png";
  
  export default function Home() {
    return (
      &lt;div className="container"&gt;
        &lt;div className="row"&gt;
          &lt;MenuButton title="home "&gt;
            &lt;img src={menuicon} /&gt;
          &lt;/MenuButton&gt;
          &lt;MenuButton title="account" /&gt;
          &lt;MenuButton title="create new" /&gt;
        &lt;/div&gt;
        &lt;div className="row"&gt;
          &lt;div className="col-md-12"&gt;
            &lt;div className="signin-btns"&gt;&lt;/div&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    );
  }
  </code></pre>
  
  <p>I am trying to import an image file "menu-icon.png" which is located in "projectfolder/public/images".</p>
  
  <p>I tried to import it using the following imports :-</p>
  
  <ol>
  <li>import menuicon from "images/menu-icon.png" returned the following error :-</li>
  </ol>
  
  <blockquote>
    <p>./src/pages/Home.js Module not found: Can't resolve
    'images/menu-icon.png' in 'C:\Users\AHMAD\project\src\pages'</p>
  </blockquote>
  
  <ol start="2">
  <li>import menuicon from "/images/menu-icon.png";</li>
  </ol>
  
  <blockquote>
    <p>./src/pages/Home.js Module not found: You attempted to import
    /images/menu-icon.png which falls outside of the project src/
    directory. Relative imports outside of src/ are not supported.</p>
  </blockquote>
  
  <ol start="3">
  <li>import menuicon from "../../images/menu-icon.png";</li>
  </ol>
  
  <blockquote>
    <p>./src/pages/Home.js Module not found: You attempted to import
    ../../images/menu-icon.png which falls outside of the project src/
    directory. Relative imports outside of src/ are not supported.</p>
  </blockquote>
  
  <p>I am using the ReactJS version : "^16.13.1" with "react-router-dom": "^5.1.2"</p>