Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C create-react-app
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 1,547
    • Issues 1,547
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 417
    • Merge requests 417
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Meta
  • create-react-app
  • Issues
  • #7753
Closed
Open
Issue created Sep 29, 2019 by Administrator@rootContributor

TypeError: Cannot read property 'forEach' of undefined if object destructing with rest props is used

Created by: paveltiunov

Describe the bug

Compilation fails with TypeError: Cannot read property 'forEach' of undefined if object destructing with rest props is used in npx created app. Works with yarn though.

Versions of react-scripts affected: 3.1.0, 3.1.1 (with different error messages), 3.1.2 Most recent react-scripts version that works: 3.0.1

Did you try recovering your dependencies?

npm --version: 6.11.3

Which terms did you search for in User Guide?

TypeError: Cannot read property 'forEach' of undefined

Environment

$ npx create-react-app --info

Environment Info:

  System:
    OS: macOS 10.14
    CPU: (8) x64 Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz
  Binaries:
    Node: 12.11.0 - ~/.nvm/versions/node/v12.11.0/bin/node
    Yarn: Not Found
    npm: 6.11.3 - ~/.nvm/versions/node/v12.11.0/bin/npm
  Browsers:
    Chrome: 77.0.3865.90
    Firefox: 67.0
    Safari: 12.0
  npmPackages:
    react: ^16.10.1 => 16.10.1 
    react-dom: ^16.10.1 => 16.10.1 
    react-scripts: 3.1.2 => 3.1.2 
  npmGlobalPackages:
    create-react-app: Not Found

(paste the output of the command here.)

Steps to reproduce

(Write your steps here:)

  1. Create new app using npx: $ npx create-react-app error-test. Make sure yarn is not installed.
  2. Go to error-test/src/App.js and add following code to the end of the file:
const testCase = {
  restObjectPropsFails: ({ id, ...item }) => {
    return null;
  }
}
  1. Run $ npm start from error-test directory

Expected behavior

Application is compiled correctly

Actual behavior

Compilation failed with message:

Failed to compile.

./src/App.js
TypeError: Cannot read property 'forEach' of undefined

Reproducible demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Assignee
Assign to
Time tracking