You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Next.js webpack configuration detection failed with the following error TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
#880
Open
jantimon opened this issue
Jan 30, 2024
· 0 comments
· May be fixed by #881
Next.js Webpack Configuration Detection Fails in Depcheck
When using depcheck with a Next.js project, the detection of the webpack configuration fails. The error encountered is a TypeError [ERR_INVALID_ARG_TYPE], stating that the "paths[0]" argument must be of type string, but received undefined. This issue seems to stem from the way Next.js handles the .context of a webpack config, which is always a filepath. This mismatch in expectations causes depcheck to fail in processing the webpack configuration correctly.
Code Snippets
Where the dependency is used:
// next.config.jsconst{ withYak }=require("next-yak/withYak");constnextConfig={// your next.js config};module.exports=withYak(nextConfig);
Versions
node -v: 20.9.0
depcheck --version: 1.4.7
Possible fix:
I tried the following in our codebase and was able to fix the bug:
Bug Description
Next.js Webpack Configuration Detection Fails in Depcheck
When using
depcheck
with a Next.js project, the detection of the webpack configuration fails. The error encountered is aTypeError [ERR_INVALID_ARG_TYPE]
, stating that the"paths[0]" argument must be of type string, but received undefined
. This issue seems to stem from the way Next.js handles the.context
of a webpack config, which is always a filepath. This mismatch in expectations causesdepcheck
to fail in processing the webpack configuration correctly.Code Snippets
Where the dependency is used:
Versions
node -v
: 20.9.0depcheck --version
: 1.4.7Possible fix:
I tried the following in our codebase and was able to fix the bug:
The text was updated successfully, but these errors were encountered: