Why is the image not shown when I compile the command npm run build, in React?

0

I have the following problem, I am importing an image and with the command npm start if it is shown, but when I do the command npm run build, it turns out that it does not appear, but navigating in its DOM, its route is fine. Reading I found that the right thing to do is to import them and that's how I got it

import React, { Component } from 'react';
import imagen1 from '../img/vaso.jpg';
// const imagen1 = require('../img/vaso.jpg');
export default class ElementosSeenapse extends Component {
  render() {
    return(
     <div>
       <img className = 'container-starbucks'
         src = {imagen1}
         alt = "deberia aparecer una imagen"/>
     </div>
   );
  }
}

even already use the option of require .. and nothing, the routes are, src / components / Elements.jsx and the image is in src / img / vaso.jpg

I enclose a screenshot, so you can see what error throws at me, but at the same time the route is fine, because it generates it with everything and its sha. I hope you can help me, thank you in advance!

    
asked by Nancy Zj 23.01.2018 в 21:03
source

0 answers