Repository: create-react-app
Issue: react-scripts build gives error: "Failed to compile. Cannot read properties of undefined (reading 'pop')" on npm@10.2.0 node@v21.0.0 (using node:latest docker image)
Labels: needs triage,issue: bug report

### Describe the bug

react-scripts build gives error: "Failed to compile. Cannot read properties of undefined (reading 'pop')" on npm@10.2.0 node@v21.0.0 (using node:slim docker image). 
```
react-scripts --max_old_space_size=4096 build
Creating an optimized production build...
Failed to compile.
Cannot read properties of undefined (reading 'pop')
```

Pls note that node:slim is v21 which was released 20-Oct. The same build runs fine when using node:20-slim which has npm@10.1.0 and node@v20.8.1
```
react-scripts --max_old_space_size=4096 build
Creating an optimized production build...
Compiled successfully.
```

### Did you try recovering your dependencies?

<!--
  Your module tree might be corrupted, and that might be causing the issues.
  Let's try to recover it. First, delete these files and folders in your project:

    * node_modules
    * package-lock.json
    * yarn.lock

  Then you need to decide which package manager you prefer to use.
  We support both npm (https://npmjs.com) and yarn (https://yarnpkg.com/).
  However, **they can't be used together in one project** so you need to pick one.

  If you decided to use npm, run this in your project directory:

    npm install -g npm@latest
    npm install

  This should fix your project.

  If you decided to use yarn, update it first (https://yarnpkg.com/en/docs/install).
  Then run in your project directory:

    yarn

  This should fix your project.

  Importantly, **if you decided to use yarn, you should never run `npm install` in the project**.
  For example, yarn users should run `yarn add <library>` instead of `npm install <library>`.
  Otherwise your project will break again.

  Have you done all these steps and still see the issue?
  Please paste the output of `npm --version` and/or `yarn --version` to confirm.
-->

Yes. Does not fix the issue. 

### Which terms did you search for in User Guide?

<!--
  There are a few common documented problems, such as watcher not detecting changes, or build failing.
  They are described in the Troubleshooting section of the User Guide:

  https://facebook.github.io/create-react-app/docs/troubleshooting

  Please scan these few sections for common problems.
  Additionally, you can search the User Guide itself for something you're having issues with:

  https://facebook.github.io/create-react-app/

  If you didn't find the solution, please share which words you searched for.
  This helps us improve documentation for future readers who might encounter the same problem.
-->

Not done. 

### Environment

<!--
  To help identify if a problem is specific to a platform, browser, or module version, information about your environment is required.
  This enables the maintainers quickly reproduce the issue and give feedback.

  Run the following command in your React app's folder in terminal.
  Note: The result is copied to your clipboard directly.

  `npx create-react-app --info`

  Paste the output of the command in the section below.
-->

(paste the output of the command here.)

### Steps to reproduce

<!--
  How would you describe your issue to someone who doesn’t know you or your project?
  Try to write a sequence of steps that anybody can repeat to see the issue.
-->

(Write your steps here:)

1.
2.
3.

### Expected behavior

<!--
  How did you expect the tool to behave?
  It’s fine if you’re not sure your understanding is correct.
  Just write down what you thought would happen.
-->

(Write what you thought would happen.)

### Actual behavior

<!--
  Did something go wrong?
  Is something broken, or not behaving as you expected?
  Please attach screenshots if possible! They are extremely helpful for diagnosing issues.
-->

```
0 verbose cli /usr/bin/node /usr/bin/npm
1 info using npm@10.2.1
2 info using node@v21.0.0
3 timing npm:load:whichnode Completed in 3ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 0ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/app/.npmrc Completed in 4ms
10 timing config:load:project Completed in 4ms
11 timing config:load:file:/root/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 9ms
17 timing npm:load:configload Completed in 9ms
18 timing config:load:flatten Completed in 1ms
19 timing npm:load:mkdirpcache Completed in 5ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm run build
22 verbose argv "run" "--loglevel" "verbose" "build"
23 timing npm:load:setTitle Completed in 0ms
24 timing npm:load:display Completed in 4ms
25 verbose logfile logs-max:10 dir:/root/.npm/_logs/2023-10-21T10_39_47_012Z-
26 verbose logfile /root/.npm/_logs/2023-10-21T10_39_47_012Z-debug-0.log
27 timing npm:load:logFile Completed in 6ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 40ms
31 silly logfile done cleaning log files
32 timing command:run Completed in 112018ms
33 verbose exit 1
34 timing npm Completed in 112088ms
35 verbose code 1
```

### Reproducible demo

<!--
  If you can, please share a project that reproduces the issue.
  This is the single most effective way to get an issue fixed soon.

  There are two ways to do it:

    * Create a new app and try to reproduce the issue in it.
      This is useful if you roughly know where the problem is, or can’t share the real code.

    * Or, copy your app and remove things until you’re left with the minimal reproducible demo.
      This is useful for finding the root cause. You may then optionally create a new project.

  This is a good guide to creating bug demos: https://stackoverflow.com/help/mcve
  Once you’re done, push the project to GitHub and paste the link to it below:
-->

(Paste the link to an example project and exact instructions to reproduce the issue.)

<!--
  What happens if you skip this step?

  We will try to help you, but in many cases it is impossible because crucial
  information is missing. In that case we'll tag an issue as having a low priority,
  and eventually close it if there is no clear direction.

  We still appreciate the report though, as eventually somebody else might
  create a reproducible example for it.

  Thanks for helping us help you!
-->