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
Not working with PNPM #16471
Comments
From a preliminary investigation, we found that Next.js's server-renderer bundler is not correctly externalizing modules installed by PNPM. For example, if we compare the file For Yarn we will see this:
...whereas for PNPM we see this:
...along with full copies of every NPM dependency, copied inline into every .js file. For example the same is seen in other files As a result, React reports a warning about hooks. The warning is complaining that multiple instances of React are getting loaded (into the Node.js server-side renderer, not the web browser runtime). Next.js seems to be using Webpack to bundle everything, so maybe it is just a configuration problem. Webpack itself certainly is compatible with PNPM. |
The webpack configuration is here: packages/next/build/webpack-config.ts It references packages/next/lib/resolve-request.ts, which looks to be doing custom module resolution. Perhaps it does not handle symlinks correctly according to the Node.js standard. |
Thank you @bitfrost for the PR, I hope that @Timer or @timneutkens can merge. |
Can not use Next.js 9.5+ because of vercel/next.js#16471
Closing as fixed by #17279 |
@Timer I think that has been partially fixed. It still does not work when deploying to Vercel.
I spent a lot of time yesterday trying to reproduce it locally but I have no idea what is different between my environment and Vercel build pipeline. What I tried so far:
Workaround: Versions: package.json
|
@vasiliicuhar try this: #20949 |
This is still very broken... Here's a minimal reproducible repo https://github.com/looopdotdev/looop-2.1 I override the install command in Vercel like so All works fine with my app, until I add Please help. I'm about to go live with my site and need to simply add some meta data. I really don't want to have to move away from pnpm or Vercel. Thanks 🙏 |
It seems like adding "--shamefully-hoist" in the install command fixes it EDIT: DOESN'T WORK FOR Next.js 12 Serverless Functions in Vercel EDIT2: IT WORKS AGAIN FOR Next.js 12.0.3 🎉 |
Dude, thanks so much. Literally save my bacon!!! |
These are my Vercel command overrides which seem to work (for https://github.com/elliottsj/elliott.dev): @danvoyce I'm curious about the underlying error for your 500 page. Anything in your app's logs? |
I could reproduce this issue and I got the most useless error possible
I feel like that recommendation is not the best one, this uses all the pnpm cache and everything seems to be working fine, very fast builds (faster than yarn & npm) npx pnpm install --store=node_modules/.pnpm-store --shamefully-hoist |
@PabloSzx I suppose it's a tradeoff. Unfortunately For example, let's say your project declares a dependency on With But if If forced to choose between Of course, ideally Vercel should cache |
Just to add to data here: We're running Next on a non-Vercel host, and our app also doesn't work without use of the This issue should probably be reopened, or alternatively another issue cut. It feels like a fairly high-quality bug with easy reproduction and a couple canned projects that show the issue. |
vercel CI goes into infinte loop. even this is not working |
Hmm, we have been using pnpm with no issues for a long time with no issues in many projects with next.js since the above issue was fixed (no use of --shamefully-hoist latest versions of pnpm) next. 10.1.3 (I will update / try the above repo later today). |
For what it's worth, I opened a PR a while ago to fix a specific issue which surfaces when using pnpm: #21048 May or may not be related to the issues people are experiencing here, but the PR includes updates to the integration tests which should help catch many potential problems. If a maintainer has time to comment on it, it would be appreciated. |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
I tried using Next.js with Rush.js which is a tool that helps developers create and maintain monorepo projects. It has support for NPM, Yarn and PNPM.
I tried using with PNPM cause it's really good compared to Yarn and NPM but I was surprised that it wasn't working with Next.js.
Next.js is working only with Yarn and NPM and it appears that Next.js's server-renderer bundler is not correctly externalizing modules with PNPM.
To Reproduce
https://github.com/zefexdeveloper/nextjs-pnpm
You can clone the repository and follow the readme. There's also a
yarn
branch with a working example.Expected behavior
It should work just like with Yarn/NPM.
Additional context
I would like to invite @octogonz (Rush.js), @timneutkens @Timer (Next.js) and @zkochan (PNPM). Great people that are related to those projects and it would be amazing to hear from them to see what might be the problem.
The text was updated successfully, but these errors were encountered: