next.js: [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 SMP Debian 5.10.162-1 (2023-01-21)
Binaries:
Node: 16.19.1
npm: 9.6.2
Yarn: 1.22.19
pnpm: N/A
Relevant packages:
next: 13.2.5-canary.12
eslint-config-next: 13.2.4
react: 18.2.0
react-dom: 18.2.0
Which area(s) of Next.js are affected? (leave empty if unsure)
No response
Link to the code that reproduces this issue
fresh/new create-next-app
To Reproduce
Simply creating a new Next.js project and running yarn build logs the following warning in the console:
npx create-next-app@latest
cd app-name
npm run build // or yarn build
result:

Describe the Bug
It’s probably linked to the issue 27650 and 35877, but it was not resolved, nor did any of this information help me fix this bug. On a freshly set-upped Debian server with the specs above, Next.js build throws the following error&warning-message (but not an error that cancels the build):
npm run build
> takeoff-frontend@0.1.0 build
> next build
info - Loaded env from /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.env.local
info - Skipping linting
info - Checking validity of types
info - Creating an optimized production build ... [webpack.cache.PackFileCacheStrategy] No pack exists at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.next/cache/webpack/server-production.pack: Error: ENOENT: no such file or directory, stat '/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.next/cache/webpack/server-production/index.pack'
<t> [webpack.cache.PackFileCacheStrategy] restore cache container: 30.694241 ms
info - Creating an optimized production build .. [webpack.cache.PackFileCacheStrategy] Pack got invalid because of write to: Compilation/modules|/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js??ruleSet[1].rules[1].oneOf[2].use!/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/pages/_app.tsx
[webpack.cache.PackFileCacheStrategy] Storing pack...
[webpack.cache.PackFileCacheStrategy] Capturing build dependencies... (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/next.config.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/ignore-loader/index.js)
<t> [webpack.cache.PackFileCacheStrategy] resolve build dependencies: 44.93478 ms
[webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of /usr/www/users: Error: EACCES: permission denied, open '/usr/www/users'
<t> [webpack.cache.PackFileCacheStrategy] snapshot build dependencies: 0.941732 ms
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
[webpack.cache.PackFileCacheStrategy] Error: Unable to snapshot resolve dependencies
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:553124
at jobError (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:276218)
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:277146
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:289658
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:1302194
at Hook.eval [as callAsync] (eval at create (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:13:28771), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:13:25925)
at AsyncQueue._handleResult (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:1301742)
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:1301593
at ReadFileContext.<anonymous> (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:289057)
[webpack.cache.PackFileCacheStrategy] No pack exists at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.next/cache/webpack/edge-server-production.pack: Error: ENOENT: no such file or directory, stat '/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.next/cache/webpack/edge-server-production/index.pack'
<t> [webpack.cache.PackFileCacheStrategy] restore cache container: 14.656235 ms
[webpack.cache.PackFileCacheStrategy] No pack exists at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.next/cache/webpack/client-production.pack: Error: ENOENT: no such file or directory, stat '/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/.next/cache/webpack/client-production/index.pack'
<t> [webpack.cache.PackFileCacheStrategy] restore cache container: 6.988857 ms
info - Creating an optimized production build . [webpack.cache.PackFileCacheStrategy] Pack got invalid because of write to: Compilation/modules|/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?absolutePagePath=private-next-pages%2F_app.tsx&page=%2F_app!
[webpack.cache.PackFileCacheStrategy] Storing pack...
[webpack.cache.PackFileCacheStrategy] Capturing build dependencies... (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/next.config.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/next-swc-loader.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/build/webpack/loaders/resolve-url-loader/index.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/sass-loader/cjs.js, /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/mini-css-extract-plugin/loader.js)
<t> [webpack.cache.PackFileCacheStrategy] resolve build dependencies: 78.69155 ms
[webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of /usr/www/users: Error: EACCES: permission denied, open '/usr/www/users'
<t> [webpack.cache.PackFileCacheStrategy] snapshot build dependencies: 0.703472 ms
<w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies
[webpack.cache.PackFileCacheStrategy] Error: Unable to snapshot resolve dependencies
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:553124
at jobError (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:276218)
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:277146
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:289658
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:1302194
at Hook.eval [as callAsync] (eval at create (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:13:28771), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:13:25925)
at AsyncQueue._handleResult (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:1301742)
at /usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:1301593
at ReadFileContext.<anonymous> (/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules/next/dist/compiled/webpack/bundle5.js:28:289057)
info - Compiled successfully
info - Collecting page data
info - Generating static pages (12/12)
info - Finalizing page optimization
Route (pages) Size First Load JS
┌ ○ / (484 ms) 2.18 kB 110 kB
├ /_app 0 B 74 kB
├ ○ /404 (540 ms) 1.77 kB 109 kB
├ ○ /500 (494 ms) 1.77 kB 109 kB
└ λ /api/hello 0 B 74 kB
+ First Load JS shared by all 88.6 kB
├ chunks/framework-cda2f1305c3d9424.js 45.2 kB
├ chunks/main-75b811eb5316bd1a.js 27.7 kB
├ chunks/pages/_app-fc698ddf2bb24351.js 297 B
├ chunks/webpack-8fa1640cc84ba8fe.js 750 B
└ css/e90b5e437a2ca258.css 14.6 kB
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
○ (Static) automatically rendered as static HTML (uses no initial props)
info - Creating an optimized production build ..
In the result above, there’s also an error Error: EACCES: permission denied, open '/usr/www/users'.
The linux user is not a superuser, so has no access to this folder, but this should not prevent the build from being successful.
After this build and exposing the webpage to a port (I can also send a link to test), the homepage “/” shows an 404 error, but the styling, some components like navigation, … (on a non-fresh build) shows.
This is the content of
the .next/cache folder:
Expected Behavior
The build should be finished without any warning/error.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
Startet an pm2 process with a proxypass pointing to the port.
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 30 (1 by maintainers)
in my case, I fixed it like this:
@WesleyRafaelp same issue persists here as well, Wes.
Same
[webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependenciesSame for me as well, tried everything advised here including
rm -rf .next & rm -rf node_modules & rm -rf package-lock.jsonandnpm iagain. None of them worked unfortunately.Not working for me. Have done all efforts advised here.
… but oddly my site is loading locally just fine, not even any errors in the browser console, just that webpack error in my server console
Yeah, I’m now getting the problem with completely fresh Next.js installs too. I made sure my Node and NPM were up to date (per the Next.js docs), trying to work this problem…
I was having this issue, alongside an issue with next yelling about EOF errors. Cleaning out .next, node_modules, and package-lock.json, and then upgrading from node v20.9.0 to v21.7.3 fixed it for me.