0

I am not able run my React Application using webpack. I am stuck with an error which I am unable to understand.

I am getting the following error on my terminal while trying to run the build:

The syntax of the command is incorrect.

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! reactjs-basics@1.0.0 build: webpack -d && copy src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the reactjs-basics@1.0.0 build script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\Pratik\AppData\Roaming\npm-cache_logs\2018-05-06T07_21_12_207Z-debug.log

npm ERR! code ELIFECYCLE

npm ERR! errno 1

npm ERR! reactjs-basics@1.0.0 start: npm run build

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the reactjs-basics@1.0.0 start script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! C:\Users\Pratik\AppData\Roaming\npm-cache_logs\2018-05-06T07_21_12_256Z-debug.log

Package.json file is as below:

{
  "name": "reactjs-basics",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "npm run build",
    "build": "webpack -d && copy src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --hot",
    "build:prod": "webpack -p && copy src/index.html dist/index.html"
  },
  "keywords": [
    "reactjs"
  ],
  "author": "Pratik Basak",
  "license": "ISC",
  "devDependencies": {
    "babel-loader": "^7.1.4",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "webpack": "^4.7.0",
    "webpack-cli": "^2.1.2",
    "webpack-dev-server": "^3.1.4"
  }
}

webpack.config.js file is as follows:

const webpack = require('webpack');
const path = require('path');

const DIST_DIR = path.resolve(__dirname, 'dist');
const SRC_DIR = path.resolve(__dirname, 'src');

var config = {
    entry: SRC_DIR + '/app/index.js',
    output: {
        path: DIST_DIR + '/app',
        filename: 'bundle.js',
        publicPath: '/app/'
    },
    module: {
        rules: [
            {
                test: /\.js?/,
                include: SRC_DIR,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2015', 'stage-2']
                }
            }
        ]
    }
};

module.exports = config;
NoviceCoder
  • 319
  • 1
  • 2
  • 15

0 Answers0