1

when I am trying to build my react app. npm run build command is failed every time. When I use npm start command everything works fine,but I can not build the app with the command. here is my error:

PS G:\self learning\react js\resort-reactjs> npm run build

> resort@0.1.0 build G:\self learning\react js\resort-reactjs
> react-scripts build

Creating an optimized production build...
Failed to compile.

static/js/main.b4300d14.js from UglifyJs
SyntaxError: Unexpected token: operator (>) [./~/contentful/dist/contentful.node.js:3909,0]


npm ERR! Windows_NT 10.0.18362
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\USER\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v12.18.1
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! resort@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the resort@0.1.0 build script 'react-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the resort package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs resort
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls resort
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     G:\self learning\react js\resort-reactjs\npm-debug.log

in my package.json file everything is updated. my package.json file here. :

{
  "name": "resort",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-icons": "^3.10.0",
    "react-router-dom": "^5.2.0",
    "react-scripts": "0.9.5",
    "styled-components": "^5.1.1"
  },
  "devDependencies": {},
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}
Sharif Ahmed
  • 160
  • 2
  • 14
  • This might answer your problem https://stackoverflow.com/a/46954832/10028748 – WilTree Aug 08 '20 at 11:10
  • you have unexpected operator '>' somewhere else your code base, run in dev mode and check – SFernando Aug 08 '20 at 13:12
  • how can i find the unexpected operator? where is no error or warning showing while running the code! @bews99 – Sharif Ahmed Aug 08 '20 at 13:24
  • 1
    SyntaxError: Unexpected token: operator (>) [./~/contentful/dist/contentful.node.js:3909,0] is the error my contentful.node.js 3909 number line: module.exports = (flag, argv) => { @bews99 – Sharif Ahmed Aug 08 '20 at 14:31

1 Answers1

0

The package.json file looks fine to me. I think it is a bug, or, at least, a poorly documented error. Try debug or just cleanup unwanted files that you dont need around the project and restart the build.