next build wont work after updating from next@9.5.3 to next@9.5.4
See original GitHub issueBug report
Describe the bug
The command next build
fails on next@9.5.4
but works fine in next@9.5.3
.
The error log is the following:
$ next build
Loaded env from /home/aalonso/workspaces/aalonso.dev/.env.local
info - Using external babel configuration from /home/aalonso/workspaces/aalonso.dev/.babelrc
info - Creating an optimized production build
Failed to compile.
./src/containers/Cover/Cover.module.scss
Error: Can't resolve '/images/cover.webp' in '/home/aalonso/workspaces/aalonso.dev/src/containers/Cover'
at runMicrotasks (<anonymous>)
> Build error occurred
Error: > Build failed because of webpack errors
at build (/home/aalonso/workspaces/aalonso.dev/node_modules/next/dist/build/index.js:15:918)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This happens when resolving an image URL from SCSS. The SCSS (./src/containers/Cover/Cover.module.scss
):
.container {
...
background: linear-gradient(rgba(0, 0, 0, 0.5), rgba(0, 0, 0, 0.5)), url('/images/cover.webp');
...
}
The folders structure of the repository:
./
|- package.json
|- .babelrc
| ...
|- src/
|- containers/
|- Cover/
|- Cover.module.scss
|- public/
|- images/
|- cover.webp
.babelrc
{
"presets": ["next/babel"],
"plugins": []
}
To Reproduce
Just run next build
on this branch of this public repository:
https://github.com/tairosonloa/aalonso.dev/tree/dependabot/npm_and_yarn/next-9.5.4
NOTE: if you run yarn build
or npm run build
, process will throw if you don’t set the env variable DOMAIN
, as it tries to execute also the npm prebuild
command, which requires the env variable to be set.
To fix it, just run export DOMAIN=aalonso.dev
on your terminal.
Here is the GitHub actions log with the failing build stage: https://github.com/tairosonloa/aalonso.dev/pull/115/checks?check_run_id=1230832954
Here is the GitHub actions log passing build step for the previous commit (before the next
dependency update):
https://github.com/tairosonloa/aalonso.dev/runs/1230831205?check_suite_focus=true
Expected behavior
The build process should resolve the image path and finish without errors, like in the previous build processes.
System information
- OS: Ubuntu-Latest (GitHub Actions and WSL)
- Version of Next.js: 9.5.4
- Version of Node.js: v12.X (GitHub Actions) and v12.19.0 (WSL)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top GitHub Comments
I’m sorry, as issue #17701 was closed I didn’t see it was a duplicated. Best regards
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.