facebook / create-react-app

Set up a modern web app by running one command.
https://create-react-app.dev
MIT License
102.71k stars 26.85k forks source link

Travis build fails with default config due to old Node version #10552

Open Glusk opened 3 years ago

Glusk commented 3 years ago

Describe the bug

The default config for Travis CI on this page (running-tests.md) suggests the use of Node 8.

Create React App, however, has moved on and some of its dependencies require a later Node version so the CI build fails with very strange and unhelpful warnings.

Setting Node version to 12 in .travis.yml resolves the issue.

Did you try recovering your dependencies?

No.

Which terms did you search for in User Guide?

"Travis CI"

Environment

Environment on my local system:

Environment Info:

  current version of create-react-app: 4.0.2
  running from C:\Users\<censored-username>\AppData\Roaming\npm-cache\_npx\10984\node_modules\create-react-app

  System:
    OS: Windows 10 10.0.19041
    CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
  Binaries:
    Node: 12.18.0 - C:\Program Files\nodejs\node.EXE
    Yarn: Not Found
    npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 88.0.4324.146
    Edge: Spartan (44.19041.423.0), Chromium (88.0.705.68)
    Internet Explorer: 11.0.19041.1
  npmPackages:
    react: ^17.0.1 => 17.0.1
    react-dom: ^17.0.1 => 17.0.1
    react-scripts: 4.0.2 => 4.0.2
  npmGlobalPackages:
    create-react-app: Not Found

Steps to reproduce

  1. Create a new react app npx create-react-app app-name
  2. Add .travis.yml from the docs to the project
  3. Push the changes to GitHub

Expected behavior

I expected a clean CI build on a fresh project.

Actual behavior

I don't think this is relevant but pasting it anyway. Build fails with:

> react-scripts build
/home/travis/build/Glusk/app-name/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
      } catch {
              ^
SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/travis/build/Glusk/app-name/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app-name@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the app-name@0.1.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!     /home/travis/.npm/_logs/2021-02-14T13_39_49_905Z-debug.log
The command "npm run build" exited with 1.
0.41s$ npm test
> app-name@0.1.0 test /home/travis/build/Glusk/app-name
> react-scripts test
/home/travis/build/Glusk/app-name/node_modules/jest/node_modules/jest-cli/build/cli/index.js:227
    } catch {
            ^
SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/travis/build/Glusk/app-name/node_modules/jest/node_modules/jest-cli/build/index.js:13:12)
npm ERR! Test failed.  See above for more details.
The command "npm test" exited with 1.

Reproducible demo

/

prahaladbelavadi commented 3 years ago

Same issue. The react build script fails when generating the build within docker;

Tried deleting the local node_modules and everything. Some stack overflow answers indicate that it can be fixed with upgrading the local npm and node versions to something above 10. Both my local env and the docker env is 14; On macOS big Sur.

Reference:

Screenshot 2021-05-14 at 11 28 10