Issue after building with importing image to React app












0















I'm importing images and add it to my react app like this:



import housePhoto from '../../images/photo/my-house1.png';

class House extends Component {
constructor(props) {
super(props);
}

render() {
return (
<a href='#'>
<img src={housePhoto} alt=''/>
</a>
)};


but when I do




npm run nodemon




I have an issue in console:




/home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
throw err;
^



SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
Unexpected character '�' (1:0)




How can I fix it?
My webpack.config.js
global.Promise = require('bluebird');



const webpack            = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');

const publicPath = 'http://localhost:8050/public/assets';
const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';

const plugins = [
new webpack.DefinePlugin({
'process.env': {
BROWSER: JSON.stringify(true),
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
}
}),
new ExtractTextPlugin(cssName)
];

if (process.env.NODE_ENV === 'production') {
plugins.push(
new CleanWebpackPlugin([ 'public/assets/' ], {
root: __dirname,
verbose: true,
dry: false
})
);
plugins.push(new webpack.optimize.DedupePlugin());
plugins.push(new webpack.optimize.OccurenceOrderPlugin());
}

module.exports = {
entry: ['babel-polyfill', './src/client.js'],
debug: process.env.NODE_ENV !== 'production',
resolve: {
root: path.join(__dirname, 'src'),
modulesDirectories: [ 'node_modules' ],
extensions: ['', '.js', '.jsx']
},
plugins,
output: {
path: `${__dirname}/public/assets/`,
filename: jsName,
publicPath
},
module: {
loaders: [
{
test: /.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
},
{
test: /.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
},
{ test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
{ test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
{ test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
{ test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
{ test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
{
test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
exclude: [/node_modules/, /public/] },
{ test: /.json$/, loader: 'json-loader' }
]
},
eslint: { configFile: '.eslintrc' },
devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
devServer: {
headers: { 'Access-Control-Allow-Origin': '*' }
}
};









share|improve this question



























    0















    I'm importing images and add it to my react app like this:



    import housePhoto from '../../images/photo/my-house1.png';

    class House extends Component {
    constructor(props) {
    super(props);
    }

    render() {
    return (
    <a href='#'>
    <img src={housePhoto} alt=''/>
    </a>
    )};


    but when I do




    npm run nodemon




    I have an issue in console:




    /home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
    throw err;
    ^



    SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
    Unexpected character '�' (1:0)




    How can I fix it?
    My webpack.config.js
    global.Promise = require('bluebird');



    const webpack            = require('webpack');
    const path = require('path');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    const CleanWebpackPlugin = require('clean-webpack-plugin');

    const publicPath = 'http://localhost:8050/public/assets';
    const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
    const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';

    const plugins = [
    new webpack.DefinePlugin({
    'process.env': {
    BROWSER: JSON.stringify(true),
    NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
    }
    }),
    new ExtractTextPlugin(cssName)
    ];

    if (process.env.NODE_ENV === 'production') {
    plugins.push(
    new CleanWebpackPlugin([ 'public/assets/' ], {
    root: __dirname,
    verbose: true,
    dry: false
    })
    );
    plugins.push(new webpack.optimize.DedupePlugin());
    plugins.push(new webpack.optimize.OccurenceOrderPlugin());
    }

    module.exports = {
    entry: ['babel-polyfill', './src/client.js'],
    debug: process.env.NODE_ENV !== 'production',
    resolve: {
    root: path.join(__dirname, 'src'),
    modulesDirectories: [ 'node_modules' ],
    extensions: ['', '.js', '.jsx']
    },
    plugins,
    output: {
    path: `${__dirname}/public/assets/`,
    filename: jsName,
    publicPath
    },
    module: {
    loaders: [
    {
    test: /.css$/,
    loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
    },
    {
    test: /.less$/,
    loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
    },
    { test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
    { test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
    { test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
    { test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
    { test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
    {
    test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
    exclude: [/node_modules/, /public/] },
    { test: /.json$/, loader: 'json-loader' }
    ]
    },
    eslint: { configFile: '.eslintrc' },
    devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
    devServer: {
    headers: { 'Access-Control-Allow-Origin': '*' }
    }
    };









    share|improve this question

























      0












      0








      0








      I'm importing images and add it to my react app like this:



      import housePhoto from '../../images/photo/my-house1.png';

      class House extends Component {
      constructor(props) {
      super(props);
      }

      render() {
      return (
      <a href='#'>
      <img src={housePhoto} alt=''/>
      </a>
      )};


      but when I do




      npm run nodemon




      I have an issue in console:




      /home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
      throw err;
      ^



      SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
      Unexpected character '�' (1:0)




      How can I fix it?
      My webpack.config.js
      global.Promise = require('bluebird');



      const webpack            = require('webpack');
      const path = require('path');
      const ExtractTextPlugin = require('extract-text-webpack-plugin');
      const CleanWebpackPlugin = require('clean-webpack-plugin');

      const publicPath = 'http://localhost:8050/public/assets';
      const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
      const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';

      const plugins = [
      new webpack.DefinePlugin({
      'process.env': {
      BROWSER: JSON.stringify(true),
      NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
      }
      }),
      new ExtractTextPlugin(cssName)
      ];

      if (process.env.NODE_ENV === 'production') {
      plugins.push(
      new CleanWebpackPlugin([ 'public/assets/' ], {
      root: __dirname,
      verbose: true,
      dry: false
      })
      );
      plugins.push(new webpack.optimize.DedupePlugin());
      plugins.push(new webpack.optimize.OccurenceOrderPlugin());
      }

      module.exports = {
      entry: ['babel-polyfill', './src/client.js'],
      debug: process.env.NODE_ENV !== 'production',
      resolve: {
      root: path.join(__dirname, 'src'),
      modulesDirectories: [ 'node_modules' ],
      extensions: ['', '.js', '.jsx']
      },
      plugins,
      output: {
      path: `${__dirname}/public/assets/`,
      filename: jsName,
      publicPath
      },
      module: {
      loaders: [
      {
      test: /.css$/,
      loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
      },
      {
      test: /.less$/,
      loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
      },
      { test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
      { test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
      { test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
      { test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
      { test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
      {
      test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
      exclude: [/node_modules/, /public/] },
      { test: /.json$/, loader: 'json-loader' }
      ]
      },
      eslint: { configFile: '.eslintrc' },
      devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
      devServer: {
      headers: { 'Access-Control-Allow-Origin': '*' }
      }
      };









      share|improve this question














      I'm importing images and add it to my react app like this:



      import housePhoto from '../../images/photo/my-house1.png';

      class House extends Component {
      constructor(props) {
      super(props);
      }

      render() {
      return (
      <a href='#'>
      <img src={housePhoto} alt=''/>
      </a>
      )};


      but when I do




      npm run nodemon




      I have an issue in console:




      /home/jack/***/node_modules/babel-register/node_modules/babel-core/lib/transformation/file/index.js:558
      throw err;
      ^



      SyntaxError: /home/jack/Документы/*-test/front/src/images/***.png:
      Unexpected character '�' (1:0)




      How can I fix it?
      My webpack.config.js
      global.Promise = require('bluebird');



      const webpack            = require('webpack');
      const path = require('path');
      const ExtractTextPlugin = require('extract-text-webpack-plugin');
      const CleanWebpackPlugin = require('clean-webpack-plugin');

      const publicPath = 'http://localhost:8050/public/assets';
      const cssName = process.env.NODE_ENV === 'production' ? 'styles-[hash].css' : 'styles.css';
      const jsName = process.env.NODE_ENV === 'production' ? 'bundle-[hash].js' : 'bundle.js';

      const plugins = [
      new webpack.DefinePlugin({
      'process.env': {
      BROWSER: JSON.stringify(true),
      NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
      }
      }),
      new ExtractTextPlugin(cssName)
      ];

      if (process.env.NODE_ENV === 'production') {
      plugins.push(
      new CleanWebpackPlugin([ 'public/assets/' ], {
      root: __dirname,
      verbose: true,
      dry: false
      })
      );
      plugins.push(new webpack.optimize.DedupePlugin());
      plugins.push(new webpack.optimize.OccurenceOrderPlugin());
      }

      module.exports = {
      entry: ['babel-polyfill', './src/client.js'],
      debug: process.env.NODE_ENV !== 'production',
      resolve: {
      root: path.join(__dirname, 'src'),
      modulesDirectories: [ 'node_modules' ],
      extensions: ['', '.js', '.jsx']
      },
      plugins,
      output: {
      path: `${__dirname}/public/assets/`,
      filename: jsName,
      publicPath
      },
      module: {
      loaders: [
      {
      test: /.css$/,
      loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader')
      },
      {
      test: /.less$/,
      loader: ExtractTextPlugin.extract('style-loader', 'css-loader!postcss-loader!less-loader')
      },
      { test: /.gif$/, loader: 'url-loader?limit=10000&mimetype=image/gif' },
      { test: /.jpg$/, loader: 'url-loader?limit=10000&mimetype=image/jpg' },
      { test: /.png$/, loader: 'url-loader?limit=10000&mimetype=image/png' },
      { test: /.svg/, loader: 'url-loader?limit=26000&mimetype=image/svg+xml' },
      { test: /.(woff|woff2|ttf|eot)/, loader: 'url-loader?limit=1' },
      {
      test: /.jsx?$/, loader: process.env.NODE_ENV !== 'production' ? 'react-hot!babel!eslint-loader' : 'babel',
      exclude: [/node_modules/, /public/] },
      { test: /.json$/, loader: 'json-loader' }
      ]
      },
      eslint: { configFile: '.eslintrc' },
      devtool: process.env.NODE_ENV !== 'production' ? 'source-map' : null,
      devServer: {
      headers: { 'Access-Control-Allow-Origin': '*' }
      }
      };






      reactjs image webpack webpack-dev-server nodemon






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 28 '18 at 21:22









      JackJack

      648




      648
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Problem solved by changing img tag:



          <img src={require('../../images/photo/my-house1.png')} />





          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528325%2fissue-after-building-with-importing-image-to-react-app%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Problem solved by changing img tag:



            <img src={require('../../images/photo/my-house1.png')} />





            share|improve this answer




























              0














              Problem solved by changing img tag:



              <img src={require('../../images/photo/my-house1.png')} />





              share|improve this answer


























                0












                0








                0







                Problem solved by changing img tag:



                <img src={require('../../images/photo/my-house1.png')} />





                share|improve this answer













                Problem solved by changing img tag:



                <img src={require('../../images/photo/my-house1.png')} />






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 29 '18 at 13:06









                JackJack

                648




                648
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53528325%2fissue-after-building-with-importing-image-to-react-app%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

                    Calculate evaluation metrics using cross_val_predict sklearn

                    Insert data from modal to MySQL (multiple modal on website)