Hey, I updated laravel mix in my app to the latest version. npm run dev command runs ok, but when I run the npm run watch-poll and make any change in my sass files I get this error:
/home/vagrant/Code/flixme/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145
if(key.startsWith(what))
^
TypeError: Cannot read property 'startsWith' of undefined
at Storage.purge (/home/vagrant/Code/flixme/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145:10)
at Storage.purge (/home/vagrant/Code/flixme/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:150:9)
at CachedInputFileSystem.purge (/home/vagrant/Code/flixme/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:259:20)
at EventEmitter.watcher.once (/home/vagrant/Code/flixme/node_modules/webpack/lib/node/NodeWatchFileSystem.js:42:26)
at EventEmitter.g (events.js:291:16)
at emitTwo (events.js:106:13)
at EventEmitter.emit (events.js:191:7)
at EventEmitter._onTimeout (/home/vagrant/Code/flixme/node_modules/watchpack/lib/watchpack.js:142:7)
at ontimeout (timers.js:365:14)
at tryOnTimeout (timers.js:237:5)
at Timer.listOnTimeout (timers.js:207:5)
Error log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'run', 'watch-poll' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prewatch-poll', 'watch-poll', 'postwatch-poll' ]
5 info lifecycle @~prewatch-poll: @
6 info lifecycle @~watch-poll: @
7 verbose lifecycle @~watch-poll: unsafe-perm in lifecycle true
8 verbose lifecycle @~watch-poll: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:/home/vagrant/Code/flixme/node_modules/.bin:/home/vagrant/.composer/vendor/bin:/home/vagrant/bin:/home/vagrant/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle @~watch-poll: CWD: /home/vagrant/Code/flixme
10 silly lifecycle @~watch-poll: Args: [ '-c', 'npm run watch -- --watch-poll' ]
11 silly lifecycle @~watch-poll: Returned: code: 1 signal: null
12 info lifecycle @~watch-poll: Failed to exec watch-poll script
13 verbose stack Error: @ watch-poll: `npm run watch -- --watch-poll`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at EventEmitter.emit (events.js:191:7)
13 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack at emitTwo (events.js:106:13)
13 verbose stack at ChildProcess.emit (events.js:191:7)
13 verbose stack at maybeClose (internal/child_process.js:877:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid @
15 verbose cwd /home/vagrant/Code/flixme
16 verbose Linux 4.4.0-51-generic
17 verbose argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "watch-poll"
18 verbose node v6.9.1
19 verbose npm v5.3.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ watch-poll: `npm run watch -- --watch-poll`
22 error Exit status 1
23 error Failed at the @ watch-poll script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Delete your node_modules folder and package-lock.json and run npm install. It should be fixed by then.
@ruchern I deleted node_modules and yarn.lock and run again yarn. Problem still occurs. For now I changed dependency file node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:145 from if(key.startsWith(what)) to if(key && key.startsWith(what)). Then everything works, but this is not the correct solution to the problem.
https://github.com/webpack/enhanced-resolve/issues/97
This might be related to your issue.
Your issue is fixed with https://github.com/webpack/enhanced-resolve/releases/tag/v3.4.1
Most helpful comment
Your issue is fixed with https://github.com/webpack/enhanced-resolve/releases/tag/v3.4.1