question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Filesystem Cache is throwing TypeError: Cannot read property 'length' of undefined from ResolverCachePlugin

See original GitHub issue

Bug report

What is the current behavior?

Attempting to get the cache working for webpack 5. I have it working on one of my local repos, but this one (a clone of a different website), is throwing an error:

Relevant config:

  cache: {
    type: 'filesystem',
    buildDependencies: {
      config: [ '/Users/xxx/public-web/config/webpack.config.js' ]
    }
  }

Throws this error:

(node:23491) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'length' of undefined
    at getType (/Users/xxx/public-web/node_modules/enhanced-resolve/lib/util/path.js:41:12)
    at Resolver.isPrivate (/Users/xxx/public-web/node_modules/enhanced-resolve/lib/Resolver.js:446:10)
    at Resolver.parse (/Users/xxx/public-web/node_modules/enhanced-resolve/lib/Resolver.js:430:25)
    at /Users/xxx/public-web/node_modules/enhanced-resolve/lib/ParsePlugin.js:33:29
    at _next0 (eval at create (/Users/xxx/public-web/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:8:1)
    at eval (eval at create (/Users/xxx/public-web/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:30:1)
    at /Users/xxx/public-web/node_modules/webpack/lib/cache/ResolverCachePlugin.js:199:17
    at Hook.eval [as callAsync] (eval at create (/Users/xxx/public-web/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:22:1)
    at Resolver.doResolve (/Users/xxx/public-web/node_modules/enhanced-resolve/lib/Resolver.js:398:16)
    at doRealResolve (/Users/xxx/public-web/node_modules/webpack/lib/cache/ResolverCachePlugin.js:138:13)

Setting the webpack config config: false eliminates the error and the build runs normally.

If the current behavior is a bug, please provide the steps to reproduce.

I see directories being created under my working repo in the node_modules/.cache folder, but not on my problem repo. A .cache folder is created, but no webpack or webpack/client-development folders.

What is the expected behavior?

Cannot figure out why one repo is throwing this error and the other is not.

Other relevant information: webpack version: 5.0.0 Node.js version: 14.13.1 Operating System: MacOS Catalina 10.15.7 Additional tools:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:65 (33 by maintainers)

github_iconTop GitHub Comments

3reactions
alexander-akaitcommented, Oct 13, 2020

@egs33 big thanks, found the problem

2reactions
alexander-akaitcommented, Oct 22, 2020

Yes, I found bug, two problems:

  • bug in sass-loader
  • ugly error from webpack when you run:
const resolve = loaderContext.getResolve(options); 

resolve(context,  undefined);
// or resolve(undefined,  undefined)

WIP on first


I even can tell you why there is an error with node-sass and no problems with sass 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack refreshing whole cache after exception ...
So we activated the Webpack filesystem cache: ... failed: TypeError: Cannot read property 'hasStartTime' of undefined.
Read more >
Cannot read property 'length' of undefined on forge/cli v1.3.4
After downloading a working codebase I started seeing the following error: Error: Cannot read property 'length' of undefined TypeError: ...
Read more >
cannot spy the getadvanddealercodes property because it is ...
webpack/webpackFilesystem Cache is throwing TypeError: Cannot read property 'length' of undefined from ResolverCachePlugin#11668. Created about 2 years ago.
Read more >
Typeerror: Cannot Read Property 'length' of Undefined
The length property returns a number for essentially any object in JavaScript. Typeerrors can be thrown when attempting to change a value that ......
Read more >
webpack @ 5.0.0-beta.12 .. 5.0.0-beta.13 - Package Diff
@property {Set<Module>} resultingAvailableModules set of modules available ... +makeSerializable(CacheEntry, "webpack/lib/cache/ResolverCachePlugin");.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found