reactjs-basics icon indicating copy to clipboard operation
reactjs-basics copied to clipboard

windows 8 :The syntax of the command is incorrect. npm ERR! code ELIFECYCLE

Open vishalsdoijode opened this issue 7 years ago • 6 comments

I had tough time setting up this simpe solution on windows ,seems like it is very outdated

bundle.js 3.11 kB 0 [emitted] main [0] ./src/app/index.js 40 bytes {0} [built] The syntax of the command is incorrect. npm ERR! code ELIFECYCLE

output :

bundle.js 3.11 kB 0 [emitted] main [0] ./src/app/index.js 40 bytes {0} [built] The syntax of the command is incorrect. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: webpack -d && copy src/index.html dist/index.html && webpack-dev-server --content-base sr c/ --inline --hot npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Not sure if it is very outdated . Dev dependencies: "devDependencies": { "babel-core": "^6.25.0", "babel-loader": "^7.1.1", "babel-preset-es2015": "^6.24.1", "babel-preset-react": "^6.24.1", "babel-preset-stage-2": "^6.24.1", "webpack": "^3.0.0", "webpack-dev-server": "^2.5.0" }

vishalsdoijode avatar Jul 09 '17 02:07 vishalsdoijode

Resolved it : resolve-url-loader is added in the prod dependencies and it it worked .

and changed the url from / to \ in windows

vishalsdoijode avatar Jul 10 '17 13:07 vishalsdoijode

@vishaldj88 i am also stuck in the same problem. It came again even it was working before. Please leaborate this part "changed the url from / to \ in windows".

murlidhar196 avatar Mar 23 '18 16:03 murlidhar196

In windows it accepts \ in place of / in your webpac config

vishalsdoijode avatar Apr 25 '18 03:04 vishalsdoijode

@vishaldj88 I am also getting the same error. but I was not able to figure where did you replace / with \ for windows.

Below is my package.json and webpack.config.js . Please tell me where did you make the change to resolve this issue. TIA.

package.json { "name": "reactjs-basics", "version": "1.0.0", "description": "Basic React JS ", "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 && cp src/index.html dist/index.html" }, "keywords": [ "reactjs", "react" ], "author": "satyadk", "license": "MIT", "dependencies": { "react": "^16.3.2", "react-dom": "^16.3.2" }, "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", "resolve-url-loader": "^2.3.0", "webpack": "^4.8.3", "webpack-cli": "^2.1.3", "webpack-dev-server": "^3.1.4" } }

webpack.config.js

var webpack = require("webpack"); var path = require("path");

var DIST_DIR = path.resolve(__dirname, "dist"); var 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;

satyadk avatar May 21 '18 08:05 satyadk

@satyadk did you resolve your problem I am getting the same error. and I am on windows too.

KidusMT avatar Jul 02 '18 07:07 KidusMT

@KidusMT

I changed as below, in package.json After change :

  "scripts": {
    "start": "npm run build",
    "build": "webpack -d && copy src\\index.html dist\\index.html /Y && webpack-dev-server --content-base src/ --inline --hot", 
    "build:prod": "webpack -p && copy src\\index.html dist\\index.html"
  },

Before change :

"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 && cp src/index.html dist/index.html"
},

satyadk avatar Jul 04 '18 19:07 satyadk