Skip to content

Next.js standalone output broken (again) when remote cached due to missing PNPM symlinks #31085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 4 tasks
ianldgs opened this issue May 6, 2025 · 0 comments · Fixed by #31138
Closed
2 of 4 tasks

Comments

@ianldgs
Copy link
Contributor

ianldgs commented May 6, 2025

Current Behavior

Symlinks are not restored when cache is used:

ls -lah dist/apps/my-project/.next/standalone/node_modules/

total 0
drwxr-xr-x   11 iserpa  staff   352B Oct  9 14:33 .
drwxr-xr-x    6 iserpa  staff   192B Oct  9 14:33 ..
drwxr-xr-x  117 iserpa  staff   3.7K Oct  9 14:33 .pnpm
drwxr-xr-x    4 iserpa  staff   128B Oct  9 14:33 babel-plugin-macros
drwxr-xr-x    5 iserpa  staff   160B Oct  9 14:33 caniuse-lite
drwxr-xr-x    7 iserpa  staff   224B Oct  9 14:33 next
drwxr-xr-x    5 iserpa  staff   160B Oct  9 14:33 react
drwxr-xr-x    6 iserpa  staff   192B Oct  9 14:33 react-dom
drwxr-xr-x    5 iserpa  staff   160B Oct  9 14:33 sass
drwxr-xr-x    5 iserpa  staff   160B Oct  9 14:33 uglify-js
drwxr-xr-x    6 iserpa  staff   192B Oct  9 14:33 webpack

Expected Behavior

When cache is used, symlinks should also be restored:

ls -lah dist/apps/my-project/.next/standalone/node_modules/

total 0
drwxr-xr-x   11 iserpa  staff   352B Oct  9 14:31 .
drwxr-xr-x    6 iserpa  staff   192B Oct  9 14:31 ..
drwxr-xr-x  117 iserpa  staff   3.7K Oct  9 14:31 .pnpm
lrwxr-xr-x    1 iserpa  staff    64B Oct  9 14:31 babel-plugin-macros -> .pnpm/[email protected]/node_modules/babel-plugin-macros
lrwxr-xr-x    1 iserpa  staff    57B Oct  9 14:31 caniuse-lite -> .pnpm/[email protected]/node_modules/caniuse-lite
lrwxr-xr-x    1 iserpa  staff    63B Oct  9 14:31 next -> .pnpm/[email protected]_pamseawcqpaoyqfggclsvtomea/node_modules/next
lrwxr-xr-x    1 iserpa  staff    37B Oct  9 14:31 react -> .pnpm/[email protected]/node_modules/react
lrwxr-xr-x    1 iserpa  staff    58B Oct  9 14:31 react-dom -> .pnpm/[email protected][email protected]/node_modules/react-dom
lrwxr-xr-x    1 iserpa  staff    35B Oct  9 14:31 sass -> .pnpm/[email protected]/node_modules/sass
lrwxr-xr-x    1 iserpa  staff    45B Oct  9 14:31 uglify-js -> .pnpm/[email protected]/node_modules/uglify-js
lrwxr-xr-x    1 iserpa  staff    68B Oct  9 14:31 webpack -> .pnpm/[email protected]_l5cbnh2nwjrm2cqen44lw7rug4/node_modules/webpack

GitHub Repo

No response

Steps to Reproduce

  1. create a nextjs project with standalone output, using pnpm as package manager
  2. setup remote cache with NX_SELF_HOSTED_REMOTE_CACHE_SERVER
  3. nx build my-project --skip-nx-cache
  4. rm -rf dist/apps/my-project/
  5. nx reset
  6. nx build my-project
  7. check output in dist/apps/my-project

Nx Report

NX   Report complete - copy this into the issue template

Node           : 22.14.0
OS             : darwin-arm64
Native Target  : aarch64-macos
pnpm           : 10.4.0

nx                     : 21.0.0
@nx/js                 : 21.0.0
@nx/jest               : 21.0.0
@nx/eslint             : 21.0.0
@nx/workspace          : 21.0.0
@nx/cypress            : 21.0.0
@nx/devkit             : 21.0.0
@nx/esbuild            : 21.0.0
@nx/eslint-plugin      : 21.0.0
@nx/module-federation  : 21.0.0
@nx/next               : 21.0.0
@nx/node               : 21.0.0
@nx/plugin             : 21.0.0
@nx/react              : 21.0.0
@nx/rollup             : 21.0.0
@nx/storybook          : 21.0.0
@nx/vite               : 21.0.0
@nx/web                : 21.0.0
@nx/webpack            : 21.0.0
typescript             : 5.7.3
---------------------------------------
Community plugins:
@jscutlery/semver      : 5.3.1
@nx-tools/nx-container : 6.1.0
@nxkit/playwright      : 3.0.2
ngx-deploy-npm         : 8.2.0
---------------------------------------
Local workspace plugins:
         @imc-trading/webgui
         @imc-trading/nx-web
---------------------------------------
Cache Usage: 385.98 MB / 92.64 GB

Failure Logs

Error: Cannot find module 'styled-jsx/package.json'

Package Manager Version

pnpm 10.4.0

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

Same as #19502, fix is probably also the same

@ianldgs ianldgs changed the title Next.js standalone output broken when cached due to missing symlinks Next.js standalone output broken when remote cached due to missing symlinks May 6, 2025
@ianldgs ianldgs changed the title Next.js standalone output broken when remote cached due to missing symlinks Next.js standalone output broken (again) when remote cached due to missing PNPM symlinks May 8, 2025
AgentEnder pushed a commit that referenced this issue May 10, 2025
…31138)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior

Symlinks in the remote cache tarball are "followed". That modifies the
output of Next.js projects using pnpm, causing a restored cache not to
work in production.

## Expected Behavior

Symlinks are added to the tarball, instead of being followed. I.e. the
cache output is not modified.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Should fix #31085.
FrozenPandaz pushed a commit that referenced this issue May 16, 2025
…31138)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior

Symlinks in the remote cache tarball are "followed". That modifies the
output of Next.js projects using pnpm, causing a restored cache not to
work in production.

## Expected Behavior

Symlinks are added to the tarball, instead of being followed. I.e. the
cache output is not modified.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Should fix #31085.

(cherry picked from commit cbb2619)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant