0
votes

I am new to react I am using webpack with babel loader in my react app

my project was running fine till i have changed my machine I have copied all the file except node_modules(installed it with npm install)

when i have tried to run or build project it is giving me error at the while this is running at the old machine correctly

enter image description here

import React from 'react';
import ReactDOM from 'react-dom';
import App from './app.js';
import {HashRouter,Route,Switch} from 'react-router-dom';
import '../node_modules/bootstrap/dist/css/bootstrap.css'


ReactDOM.render(
    <HashRouter>
        <App />
    </HashRouter>

, document.getElementById('app'));

Rs-MacBook-Pro:intra rd$ npm start

[email protected] start /Users/rd/Documents/intra webpack-dev-server --open --mode development

ℹ 「wds」: Project is running at http://localhost:8080/ ℹ 「wds」: webpack output is served from / ℹ 「wds」: Content not from webpack is served from /Users/rd/Documents/intra/public ℹ 「wds」: 404s will fallback to /index.html ℹ 「wdm」: wait until bundle finished: / ✖ 「wdm」: Hash: 53cc551e031b5ed39d70 Version: webpack 4.19.1 Time: 3596ms Built at: 2018-09-21 12:44:47 Asset Size Chunks Chunk Names bundle.js 836 KiB main [emitted] main Entrypoint main = bundle.js [./node_modules/ansi-html/index.js] 4.16 KiB {main} [built] [./node_modules/ansi-regex/index.js] 135 bytes {main} [built] [./node_modules/loglevel/lib/loglevel.js] 7.68 KiB {main} [built] [./node_modules/punycode/punycode.js] 14.3 KiB {main} [built] [./node_modules/url/url.js] 22.8 KiB {main} [built] [0] multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.js 40 bytes {main} [built] [./node_modules/sockjs-client/dist/sockjs.js] 177 KiB {main} [built] [./node_modules/strip-ansi/index.js] 161 bytes {main} [built] [./node_modules/url/util.js] 314 bytes {main} [built] [./node_modules/webpack-dev-server/client/index.js?http://localhost:8080] (webpack)-dev-server/client?http://localhost:8080 7.78 KiB {main} [built] [./node_modules/webpack-dev-server/client/overlay.js] (webpack)-dev-server/client/overlay.js 3.58 KiB {main} [built] [./node_modules/webpack-dev-server/client/socket.js] (webpack)-dev-server/client/socket.js 1.05 KiB {main} [built] [./node_modules/webpack/hot sync ^./log$] (webpack)/hot sync nonrecursive ^./log$ 170 bytes {main} [built] [./node_modules/webpack/hot/emitter.js] (webpack)/hot/emitter.js 75 bytes {main} [built] [./src/index.js] 761 bytes {main} [built] [failed] [1 error] + 11 hidden modules

ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: Unexpected token (9:4)

7 | 8 | ReactDOM.render(

9 | | ^ 10 | 11 | 12 |

@ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.js main1 ℹ 「wdm」: Failed to compile.

1

1 Answers

1
votes

Some version of babel-core and babel-loader aren't compatible together, try to update them to latest version if you don't mind to have a specific version

npm install -D babel-loader @babel/core @babel/preset-env webpack