next.js icon indicating copy to clipboard operation
next.js copied to clipboard

[webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies

Open DanielWahl opened this issue 3 years ago • 35 comments

Verify canary release

  • [X] 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: Bildschirmfoto 2023-03-22 um 13 41 14

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

> [email protected] 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 Bildschirmfoto 2023-03-22 um 13 52 00 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.

DanielWahl avatar Mar 22 '23 12:03 DanielWahl

Not quite sure if that's the root of the problem, but webpack is trying to access the base root folder of the server:

Set(8) {
  '/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend/node_modules',
  '/usr/www/users/takeoff/takeoffshow.blocknote.dev/takeoff-frontend',
  '/usr/www/users/takeoff/takeoffshow.blocknote.dev',
  '/usr/www/users/takeoff',
  '/usr/www/users',
  '/usr/www',
  '/usr',
  '/'
}

The file causing this: lib/FileSystemInfo.js:2055 --> processCapturedFiles

DanielWahl avatar Mar 24 '23 17:03 DanielWahl

any luck with this bug? I'm getting the same error on my Mac environment (MacOS Big Sur 11.7.4 Node v 16.17.0 npm v 9.6.2)

richleach avatar Mar 29 '23 00:03 richleach

just curious, did you start getting this error after you installed tailwindcss? That's when my troubles started.... Could just be a coincidence

richleach avatar Mar 29 '23 19:03 richleach

Still didn't find a solution to the problem. I'm currently not using TailwindCSS, the problem occurs even after a completely fresh Next.js install on the server.

DanielWahl avatar Mar 29 '23 20:03 DanielWahl

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....

richleach avatar Mar 29 '23 20:03 richleach

... 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

richleach avatar Mar 29 '23 20:03 richleach

I had the same today when I try building on vercel:

info - Creating an optimized production build... 20:05:01.655 | [webpack.cache.PackFileCacheStrategy] Serializing big strings (659kiB) impacts deserialization performance (consider using Buffer instead and decode when needed) 20:05:08.248 | warn - Compiled with warnings 20:05:08.248

When I build locally I see sometimes the same warning.

semy avatar Apr 18 '23 07:04 semy

I have the same error:

Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

- info Linting and checking validity of types...
- info Creating an optimized production build...
<w> [webpack.cache.PackFileCacheStrategy] Serializing big strings (659kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
- warn Compiled with warnings

../../../node_modules/.pnpm/[email protected]_3j7hb26pwgm6spbxoejtjx6xja/node_modules/next/dist/server/web/spec-extension/image-response.js
A Node.js API is used (process.turbopack at line: 14) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime

Import trace for requested module:
../../../node_modules/.pnpm/[email protected]_3j7hb26pwgm6spbxoejtjx6xja/node_modules/next/dist/server/web/spec-extension/image-response.js
../../../node_modules/.pnpm/[email protected]_3j7hb26pwgm6spbxoejtjx6xja/node_modules/next/server.js
../../../node_modules/.pnpm/[email protected]_cmp7sjki5xcmfyvhcokzzink7a/node_modules/next-auth/next/middleware.js
../../../node_modules/.pnpm/[email protected]_cmp7sjki5xcmfyvhcokzzink7a/node_modules/next-auth/middleware.js

karlo-humanmanaged avatar May 18 '23 13:05 karlo-humanmanaged

same error with version 13.4

  • warn You have enabled experimental feature (swcPlugins) in next.config.js.
  • warn Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use at your own risk.
  • info Creating an optimized production build .. [webpack.cache.PackFileCacheStrategy] Serializing big strings (659kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)
  • warn Compiled with warnings

mkmrcodes avatar May 30 '23 21:05 mkmrcodes

in my case, I fixed it like this:

  • remove node_modules, lockfile and .next folder
  • install dependencies again and run app

eddjnr avatar Jul 30 '23 17:07 eddjnr

did anyone manage to solve it? I have the same problem

WesleyRafaelp avatar Sep 01 '23 23:09 WesleyRafaelp

@WesleyRafaelp same issue persists here as well, Wes.

prodkt avatar Sep 03 '23 09:09 prodkt

what is this weird problem? C'mon Vercel and next team

ucefkh avatar Oct 10 '23 10:10 ucefkh

Resting everything solves it, at least for now

ucefkh avatar Oct 10 '23 10:10 ucefkh

Same

unhandledRejection: [Error: ENOENT: no such file or directory, stat '/Users/.../.next/cache/webpack/server-development/0.pack.gz'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'stat',
  path: '/Users/.../.next/cache/webpack/server-development/0.pack.gz'
}

kimhwanhoon avatar Oct 13 '23 08:10 kimhwanhoon

same error

PeterCastilloG avatar Oct 13 '23 14:10 PeterCastilloG

in my case, I fixed it like this:

  • remove node_modules, lockfile and .next folder
  • install dependencies again and run app

It worked for me, thanks. I was removing the "node_modules" but not "package-lock.json".

Maxdoggydog avatar Oct 26 '23 05:10 Maxdoggydog

in my case, I fixed it like this:

  • remove node_modules, lockfile and .next folder
  • install dependencies again and run app

This worked for me too, no need to remove lockfile but node_modules and .next folder. Thanks!!

fernandezAmor avatar Oct 26 '23 05:10 fernandezAmor

in my case, I fixed it like this:

  • remove node_modules, lockfile and .next folder
  • install dependencies again and run app

This worked for me too, no need to remove lockfile but node_modules and .next folder. Thanks!!

I had removed the ".next" and "node_modules" but I was still getting this error, but I when I removed "lockfile", it worked.

Maxdoggydog avatar Oct 26 '23 05:10 Maxdoggydog

in my case, I fixed it like this:

  • remove node_modules, lockfile and .next folder
  • install dependencies again and run app

Worked for me

IDNK2203 avatar Nov 09 '23 11:11 IDNK2203