Cannot read property 'replace' of undefined
alexmcmillan opened this issue · comments
I'm currently migrating a small project to use Babel v6, but I'm getting the titular error with this trace when attempting to run webpack-dev-server:
TypeError: Cannot read property 'replace' of undefined
at Tapable.join (C:\project\node_modules\memory-fs\lib\join.js:11:73)
at Tapable.<anonymous> (C:\project\node_modules\enhanced-resolve\lib\FileAppendPlugin.js:14:19)
at Tapable.applyPluginsParallelBailResult (C:\project\node_modules\tapable\lib\Tapable.js:139:14)
at Tapable.<anonymous> (C:\project\node_modules\enhanced-resolve\lib\Resolver.js:103:8)
at Tapable.Resolver.forEachBail (C:\project\node_modules\enhanced-resolve\lib\Resolver.js:196:3)
at Tapable.doResolve (C:\project\node_modules\enhanced-resolve\lib\Resolver.js:102:7)
at Tapable.resolve (C:\project\node_modules\enhanced-resolve\lib\Resolver.js:45:14)
at Tapable.resolve (C:\project\node_modules\enhanced-resolve\lib\UnsafeCachePlugin.js:23:14)
at C:\project\node_modules\webpack\lib\NormalModuleFactory.js:169:12
at C:\project\node_modules\async\lib\async.js:356:13
It appears the error is in join.js
which begins with:
module.exports = function join(path, request) {
if(request == "") return normalize(path);
...
}
Obviously, FileAppendPlugin.js
is calling join
with undefined
as the second argument but undefined != ""
, so this escape only works if an empty string is passed, and execution continues if undefined
is passed (and the rest of the function assumes a value). Is this function intentionally tossing its toys, or is this a simple oversight that could be handled with something like:
if (!request) return normalize(path);
?
Sure, I can move onto working out why FileAppendPlugin is passing undefined
(assumedly erroneously), but this problem remains.
could you tell how to update join.js? please