enhanced-resolve icon indicating copy to clipboard operation
enhanced-resolve copied to clipboard

Error when using webpack in watch mode

Open danrot opened this issue 9 years ago • 29 comments

I have updated to the latest release of this library (3.4.0), and that caused the watch script I've added to package.json (actually it is just webpack -d -w) to break. It breaks with this error message:

/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145
			if(key.startsWith(what))
			      ^

TypeError: Cannot read property 'startsWith' of undefined
    at Storage.purge (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
    at Storage.purge (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
    at CachedInputFileSystem.purge (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
    at Watchpack.watcher.once (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
    at Object.onceWrapper (events.js:318:30)
    at emitTwo (events.js:125:13)
    at Watchpack.emit (events.js:213:7)
    at Watchpack._onTimeout (/Users/daniel.rotter/Development/massiveart/sulu-minimal/node_modules/watchpack/lib/watchpack.js:142:7)
    at ontimeout (timers.js:488:11)
    at tryOnTimeout (timers.js:323:5)
    at Timer.listOnTimeout (timers.js:283:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ watch: `webpack -d -w`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The initial build works, but this error occurs after I save a file being watched. Is there some compatability issue with this release?

If I downgrade to version 3.3.0 of this library the watch task is working again.

danrot avatar Jul 24 '17 08:07 danrot

Just wanted to report the same issue.

smares avatar Jul 24 '17 08:07 smares

Also getting this issue.

peteringram0 avatar Jul 24 '17 08:07 peteringram0

Looks like we have an undefined key here, likely from commit 03ef8f2:

		for(var key of this.data.keys()) {
			if(key.startsWith(what))
				this.data.delete(key);
		}

In a rush so I had to edit it like below as a temporary workaround:

		for(var key of this.data.keys()) {
			if (typeof key !== "string") {
				continue;
			}
			if(key.startsWith(what))
				this.data.delete(key);
		}

Hope this can be fixed soon.

daohoangson avatar Jul 24 '17 09:07 daohoangson

Getting the same problem using version 3.4.0

suyi91 avatar Jul 24 '17 09:07 suyi91

+1

antonnyman avatar Jul 24 '17 09:07 antonnyman

+1

MadMikeyB avatar Jul 24 '17 09:07 MadMikeyB

+1

Alvin-Liu avatar Jul 24 '17 09:07 Alvin-Liu

Same error here.

webpack: Compiling...
/Users/Gustavo/Desktop/canvas-test/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145

                    if(key.startsWith(what))
                          ^
TypeError: Cannot read property 'startsWith' of undefined

timbergus avatar Jul 24 '17 09:07 timbergus

Same issue, had to downgrade again. Seems to work in 3.2.0.

the-architect avatar Jul 24 '17 09:07 the-architect

It even works in 3.3.0 @the-architect

smares avatar Jul 24 '17 09:07 smares

+1

timobehrens avatar Jul 24 '17 09:07 timobehrens

+1

code-by-gijs avatar Jul 24 '17 09:07 code-by-gijs

@smares yeah sorry, yarn was still installing 3.4.0.

the-architect avatar Jul 24 '17 09:07 the-architect

Just facing the same error in 3.3.0 My script: cross-env NODE_ENV=development webpack-dev-server -d --inline --hot When I edit my code and trigger the hot reload, the error shows and break the dev server

jeremyxgo avatar Jul 24 '17 09:07 jeremyxgo

+1

bongofury avatar Jul 24 '17 10:07 bongofury

+1

Kumarsammy avatar Jul 24 '17 10:07 Kumarsammy

+1

tomasztomys avatar Jul 24 '17 10:07 tomasztomys

+1

dariuszpaluch avatar Jul 24 '17 10:07 dariuszpaluch

+1

3jwddgm avatar Jul 24 '17 11:07 3jwddgm

+1

diegoprd avatar Jul 24 '17 11:07 diegoprd