Repository: next.js
Issue: Missing dependencies when using standalone output with pnpm 8
Labels: bug,Output (export/standalone)

### Verify canary release

- [X] I verified that the issue exists in the latest Next.js canary release

### Provide environment information

```bash
Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000
    Binaries:
      Node: 16.19.1
      npm: 8.19.3
      Yarn: 1.22.19
      pnpm: 8.1.0
    Relevant packages:
      next: 13.2.5-canary.32
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0
```


### Which area(s) of Next.js are affected? (leave empty if unsure)

Standalone mode (output: "standalone")

### Link to the code that reproduces this issue

https://github.com/Bubbleinpit/nextjs13-standalone-with-pnpm8

### To Reproduce

You can follow this README of the repo above to reproduce the issue. For convenience, I will also describe it here.

1. execute `next build` and copy all necessary files to output dir

```bash
pnpm build

[ -d "build" ] && rm -r build
mkdir build

cp -r ./public ./build
cp -r ./.next/standalone/* ./build
cp -r ./.next/standalone/.next ./build
cp -r ./.next/static ./build/.next
```

2. move output dir to another place and execute `node server.js` in it

```bash
mv ./build ~/build
cd ~/build
node ./server.js
```

Then you will see:

```bash
node:internal/modules/cjs/loader:1024
  throw err;
  ^

Error: Cannot find module 'styled-jsx'
Require stack:
- /Users/username/build/node_modules/next/dist/build/webpack/require-hook.js
- /Users/username/build/node_modules/next/dist/server/initialize-require-hook.js
- /Users/username/build/node_modules/next/dist/server/next-server.js
- /Users/username/build/server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)
    at Function.resolve (node:internal/modules/cjs/helpers:114:19)
    at Object.loadRequireHook (/Users/username/build/node_modules/next/dist/build/webpack/require-hook.js:38:21)
    at Object.<anonymous> (/Users/username/build/node_modules/next/dist/server/initialize-require-hook.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
    at Module.load (node:internal/modules/cjs/loader:1069:32)
    at Function.Module._load (node:internal/modules/cjs/loader:904:12)
    at Module.require (node:internal/modules/cjs/loader:1093:19)
    at require (node:internal/modules/cjs/helpers:108:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/username/build/node_modules/next/dist/build/webpack/require-hook.js',
    '/Users/username/build/node_modules/next/dist/server/initialize-require-hook.js',
    '/Users/username/build/node_modules/next/dist/server/next-server.js',
    '/Users/username/build/server.js'
  ]
}
```

### Describe the Bug

I'm using pnpm 8 and nextjs 13. And I turn on the `appDir`. I set the output mode as `standalone` to build the code on my dev computer and to deploy it on a prod server.

When I try to execute the `server.js`, it always says `Error: Cannot find module 'xxx'`.

```bash
node:internal/modules/cjs/loader:1024
  throw err;
  ^

Error: Cannot find module 'styled-jsx'
Require stack:
- /Users/username/build/node_modules/next/dist/build/webpack/require-hook.js
- /Users/username/build/node_modules/next/dist/server/initialize-require-hook.js
- /Users/username/build/node_modules/next/dist/server/next-server.js
- /Users/username/build/server.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1021:15)
    at Function.resolve (node:internal/modules/cjs/helpers:114:19)
    at Object.loadRequireHook (/Users/username/build/node_modules/next/dist/build/webpack/require-hook.js:38:21)
    at Object.<anonymous> (/Users/username/build/node_modules/next/dist/server/initialize-require-hook.js:3:19)
    at Module._compile (node:internal/modules/cjs/loader:1191:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1245:10)
    at Module.load (node:internal/modules/cjs/loader:1069:32)
    at Function.Module._load (node:internal/modules/cjs/loader:904:12)
    at Module.require (node:internal/modules/cjs/loader:1093:19)
    at require (node:internal/modules/cjs/helpers:108:18) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/username/build/node_modules/next/dist/build/webpack/require-hook.js',
    '/Users/username/build/node_modules/next/dist/server/initialize-require-hook.js',
    '/Users/username/build/node_modules/next/dist/server/next-server.js',
    '/Users/username/build/server.js'
  ]
}
```

Now I have to reinstall the dependencies in the output dir on my prod server to solve this issue. This is too much of a waste of time.

And I am sure that if I switch to use npm as the package manager, the issue will go away. I verified that.

### Expected Behavior

I can start the server successfully with the steps to reproduce.

### Which browser are you using? (if relevant)

_No response_

### How are you deploying your application? (if relevant)

_No response_