'Message 'Caching failed for pack: Error: Unable to snapshot resolve dependencies' when creating a nextjs application

I tried to create a nextjs application; when i run npm run dev, i got the following error message: <w> [webpack.cache.PackFileCacheStrategy] Caching failed for pack: Error: Unable to snapshot resolve dependencies

  1. version of Node.js : v16.13.1
  2. version of npm : v8.3.0

Then i tried to debug and i added in my next.config.js:

webpack(config){
     config.infrastructureLogging = { debug: /PackFileCache/ }
        return config;}
ready - started server on 0.0.0.0:3000, url: http://localhost:3000
    [webpack.cache.PackFileCacheStrategy] No pack exists at W:\react\cours-nextjs\.next\cache\webpack\client-development.pack: Error: ENOENT: no such file or directory, stat 'W:\react\cours-nextjs\.next\cache\webpack\client-development\index.pack'
<t> [webpack.cache.PackFileCacheStrategy] restore cache container: 30.4758 ms
    [webpack.cache.PackFileCacheStrategy] No pack exists at W:\react\cours-nextjs\.next\cache\webpack\server-development.pack: Error: ENOENT: no such file or directory, stat 'W:\react\cours-nextjs\.next\cache\webpack\server-development\index.pack'
<t> [webpack.cache.PackFileCacheStrategy] restore cache container: 30.259 ms
event - compiled client and server successfully in 3.1s (207 modules)
    [webpack.cache.PackFileCacheStrategy] Pack got invalid because of write to: ResolverCachePlugin|normal|dependencyType=|esm|path=|W:\react\cours-nextjs|request=|W:\react\cours-nextjs\node_modules\@next\react-refresh-utils\runtime.js
    [webpack.cache.PackFileCacheStrategy] Storing pack...
    [webpack.cache.PackFileCacheStrategy] Capturing build dependencies... (W:\react\cours-nextjs\next.config.js, W:\react\cours-nextjs\node_modules\next\dist\compiled\, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\next-client-pages-loader.js, W:\react\cours-nextjs\node_modules\@next\react-refresh-utils\loader.js, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\next-swc-loader.js, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\next-style-loader\index.js, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\css-loader\src\index.js, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\postcss-loader\src\index.js)
    [webpack.cache.PackFileCacheStrategy] Pack got invalid because of write to: ResolverCachePlugin|normal|dependencyType=|esm|path=|W:\react\cours-nextjs|request=|private-next-pages/_app
    [webpack.cache.PackFileCacheStrategy] Storing pack...
    [webpack.cache.PackFileCacheStrategy] Capturing build dependencies... (W:\react\cours-nextjs\next.config.js, W:\react\cours-nextjs\node_modules\next\dist\compiled\, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\next-swc-loader.js, W:\react\cours-nextjs\node_modules\next\dist\compiled\ignore-loader\index.js, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\css-loader\src\index.js, W:\react\cours-nextjs\node_modules\next\dist\build\webpack\loaders\postcss-loader\src\index.js)
<t> [webpack.cache.PackFileCacheStrategy] resolve build dependencies: 349.5088 ms
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs: Error: EINVAL: invalid argument, read
<t> [webpack.cache.PackFileCacheStrategy] snapshot build dependencies: 8.2939 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 W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:67456:13
        at jobError (W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:44464:5)
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:44527:10
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:45420:13
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:122829:5
        at Hook.eval [as callAsync] (eval at create (W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:141512:10), <anonymous>:6:1)
        at AsyncQueue._handleResult (W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:122799:21)
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:122782:11
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:45369:12
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:20032:16
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs\node_modules\@next: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs\node_modules: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs\node_modules\@napi-rs: Error: EINVAL: invalid argument, read
<t> [webpack.cache.PackFileCacheStrategy] resolve build dependencies: 314.5233 ms
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs: Error: EINVAL: invalid argument, read
<t> [webpack.cache.PackFileCacheStrategy] snapshot build dependencies: 3.9051 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 W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:67456:13
        at jobError (W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:44464:5)
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:44527:10
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:45420:13
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:122829:5
        at Hook.eval [as callAsync] (eval at create (W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:141512:10), <anonymous>:6:1)
        at AsyncQueue._handleResult (W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:122799:21)
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:122782:11
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:45369:12
        at W:\react\cours-nextjs\node_modules\next\dist\compiled\webpack\bundle5.js:20032:16
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs\node_modules: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs\node_modules\@next: Error: EINVAL: invalid argument, read
    [webpack.cache.PackFileCacheStrategy/webpack.FileSystemInfo] Error snapshotting file timestamp hash combination of W:\react\cours-nextjs\node_modules\@napi-rs: Error: EINVAL: invalid argument, read

W:\react\cours-nextjs (main)
λ   [webpack.cache.PackFileCacheStrategy] No pack exists at W:\react\cours-nextjs\.next\cache\webpack\client-development.pack: Error: ENOENT: no such file or directory, stat 'W:\react\cours-nextjs\.next\cache\webpack\client-development\index.pack'

Thanks for your help



Solution 1:[1]

Change the project directory from W:/ drive to C:/ drive. It's stupid but it works.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marcin