-
Notifications
You must be signed in to change notification settings - Fork 26.1k
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
Turbopack: "Cannot find module" when package require()
a package installed via the optionalDependencies
field in package.json
#63850
Comments
require()
a package installed via the "optionalDependecies" field in package.jsonrequire()
a package installed via the optionalDependecies
field in package.json
require()
a package installed via the optionalDependecies
field in package.jsonrequire()
a package installed via the optionalDependencies
field in package.json
This comment was marked as off-topic.
This comment was marked as off-topic.
Just double checked and it seems that this isn't specific to Turbopack? I can see the same error when running with webpack. I.e. changing the Seems Here's an example with serverComponentsExternalPackages manually added: https://codesandbox.io/p/github/pilcrowOnPaper/repro-nextjs-turbopack-optional-dependencies/csb-p9q66w/draft/tender-rain?file=%2Fnext.config.mjs |
Opened #65204 to address this. Added additional details and made sure |
You seem to be correct - apologies for that! The error was similar to the ones I got when when importing |
…65204) ## What? Initially added `@node-rs/argon2` to the list as `argon2` was already in the list to make the provided reproduction pass, however, when digging deeper into Lucia I found that `oslo` also uses `@node-rs/bcrypt`. I also looked at Lucia example [1](https://github.com/lucia-auth/examples/blob/main/nextjs-app/username-and-password/next.config.js#L2-L6) and [2](https://github.com/lucia-auth/examples/blob/main/nextjs-app/username-and-password/next.config.js#L2-L6) which show that this configuration is always added: `serverComponentsExternalPackages: ["oslo"]`. That shouldn't be needed as we keep a list of packages that can't be bundled in Next.js itself, so I've updated the list to add `oslo`, `@node-rs/argon2`, and `@node-rs/bcrypt`. This makes it so that you don't have to add additional configuration to use Lucia. Fixes #63850 <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> Closes NEXT-3264
Thanks for checking @pilcrowOnPaper, can you confirm it's fixed with |
Thanks, that seems to have fixed the issue! Though, bad timing since we're planning to remove |
Awesome, thanks for checking! Yeah it's fine to remove it later, overall it doesn't really hurt to have it external and the older version of Lucia people use would still have the version of oslo included so probably fine to leave it for a few months. |
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Link to the code that reproduces this issue
https://github.com/pilcrowOnPaper/repro-nextjs-turbopack-optional-dependencies
To Reproduce
pnpm dev
Current vs. Expected behavior
I expect the dev server to not crash
Provide environment information
Operating System: Platform: darwin Arch: arm64 Version: Darwin Kernel Version 23.4.0: Wed Feb 21 21:44:54 PST 2024; root:xnu-10063.101.15~2/RELEASE_ARM64_T6030 Available memory (MB): 36864 Available CPU cores: 11 Binaries: Node: 21.7.0 npm: 10.5.0 Yarn: N/A pnpm: 8.15.4 Relevant Packages: next: 14.2.0-canary.48 // Latest available version is detected (14.2.0-canary.48). eslint-config-next: 14.1.0 react: 18.2.0 react-dom: 18.2.0 typescript: 5.4.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
Package manager (npm, pnpm, Yarn), Turbopack (--turbo)
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
No response
PACK-2925
The text was updated successfully, but these errors were encountered: