Home > Blockchain >  error when try to run npm build on react project
error when try to run npm build on react project

Time:08-25

i'm trying to deploy my app via VPS (Ubuntu and Nginx) but this error keeps showing up, (on vs code it works fine) any idea how could i procede? thanks!

> [email protected] build /home/react-projects/portfolio
> react-scripts build

/home/react-projects/portfolio/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
  _ending;
         ^

SyntaxError: Unexpected token ;
    at Module._compile (internal/modules/cjs/loader.js:723:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/home/react-projects/portfolio/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
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.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-08-23T18_10_04_282Z-debug.log

CodePudding user response:

one way you can :

  1. go to your package.json
  2. replace "react-scripts": "..." to "react-scripts": "1.1.4",
  3. then run npm install, after that npm build

if it didn't work try :

  1. create a file .env at the root of the folder react folder
  2. type SKIP_PREFLIGHT_CHECK=true inside of .env file

this command will help you in resolving this npm error.

then try to run npm build and check it should work .

notice : this command will permanently disable this preflight check

CodePudding user response:

i solved it installing the correct versions through NVM on my web server

https://www.freecodecamp.org/news/how-to-install-node-js-on-ubuntu-and-update-npm-to-the-latest-version/

  • Related