-
Notifications
You must be signed in to change notification settings - Fork 27.4k
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
Module not found: Can't resolve './_next/static/media/b1db3e28af9ef94a-s.woff2' After set assetPrefix to '.', #47641
Comments
You're missing the part where you add this woff2 font. Could you maybe link a repo or something like that where we could actually see the project's code to diagnose this issue for ya? |
Hmm. It looks like the repro steps given are enough to reproduce. (The default template uses |
After some digging, I believe this is intentionally not working. The So I think we just need a better error message and clarify the docs. This will be invalid for other use cases like `next/image as well, but that component will already surface this via the following error message: |
Well in my case I programatically import the image file and throw it into a Image component. It works on deployments to vercel and in dev but it breaks on static. |
Can you clarify this part? What do you mean by "programmatically importing"? Maybe you can attach a reproduction? The above error is shown when you import the image in the module scope and pass it to the next.js/packages/next/src/build/webpack/loaders/next-image-loader/index.ts Lines 20 to 25 in a3acbf4
It just does not verify invalid URLs later on, as next.js/packages/next/src/shared/lib/image-loader.ts Lines 26 to 41 in a3acbf4
|
I got my images in a images folder in the src dir. I import them from that dir in my code and then dump the image into a Image component. My repo is located in https://github.com/ShiftCodeEU/shiftcode.eu |
This seems to be unrelated to the original issue though since I cannot see an |
You're right that I'm not using the asset prefix. I did have the output export enabled while testing which is why it's commented out. As far as I know and from my experience with the pages dir I was under the impression it would still work the same as it does with importing images ending up in the _next/static dir. |
@balazsorban44 I've created a PR to improve the error message #49403 |
fixes #47641 This adds a friendly error for loading a font error caused by the invalid `assetPrefix` setting. Current: <img width="747" alt="image" src="https://user-images.githubusercontent.com/250407/236685607-c03b6160-9e8c-4c88-80e1-714f6a140588.png"> This PR: <img width="890" alt="image" src="https://user-images.githubusercontent.com/250407/236685499-da4c3d69-0f97-458d-8709-dcc43475e0e9.png"> <!-- 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 or adding/fixing 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 # --> --------- Co-authored-by: JJ Kasper <[email protected]>
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
no
To Reproduce
pnpm create next-app (with default options)
modify next.config.js as following
pnpm build
then will get following error
Describe the Bug
I am not sure what happend, please help
Expected Behavior
expected
pnpm build
can work ok with assetPrefix configWhich browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: