Repository navigation
[aspnet-webpack] invalid argument since 1.0.19 #408
Description
Hi im getting the following error since updating to 1.0.19 before it was fine.
the path which causes the problem is \wwwroot
Microsoft.AspNetCore.NodeServices: Error: Unhandled rejection Error: invalid argument
at pathToArray (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\memory-fs\lib\MemoryFileSystem.js:44:10)
at MemoryFileSystem.meta (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\memory-fs\lib\MemoryFileSystem.js:61:13)
at MemoryFileSystem.statSync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\memory-fs\lib\MemoryFileSystem.js:76:21)
at D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\aspnet-webpack\WebpackDevMiddleware.js:97:33
at Array.forEach (native)
at copyRecursiveSync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\aspnet-webpack\WebpackDevMiddleware.js:93:31)
at Compiler. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\aspnet-webpack\WebpackDevMiddleware.js:79:9)
at Compiler.applyPlugins (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:26:37)
at Watching._done (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:78:17)
at Watching. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:61:18)
at Compiler.emitRecords (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:282:37)
at Watching. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:58:19)
at D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:275:11
at Compiler.applyPluginsAsync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:60:69)
at Compiler.afterEmit (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:272:8)
at Compiler. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:267:14)
From previous event:
at Compiler. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\html-webpack-plugin\index.js:197:15)
at Compiler.applyPluginsAsync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:71:13)
at Compiler.emitAssets (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:226:7)
at Watching. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:54:18)
at D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:403:12
at Compiler.next (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:67:11)
at Compiler. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\awesome-typescript-loader\src\instance.ts:471:9)
at Compiler.next (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:69:14)
at Compiler. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\CachePlugin.js:40:4)
at Compiler.applyPluginsAsync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:71:13)
at Compiler. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compiler.js:400:9)
at Compilation. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compilation.js:577:13)
at Compilation.applyPluginsAsync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:60:69)
at Compilation. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compilation.js:572:10)
at Compilation.applyPluginsAsync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:60:69)
at Compilation. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compilation.js:567:9)
at Compilation.applyPluginsAsync (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\tapable\lib\Tapable.js:60:69)
at Compilation. (D:\Repositories\Maintenance Web App\src\Maintenance.Web\node_modules\webpack\lib\Compilation.js:563:8)
Activity
JanEggers commentedon Oct 27, 2016
here the config:
webpack.common.js:
webpack.dev.js:
MarkPieszak commentedon Oct 27, 2016
@JanEggers You can see the error steaming from:
Error: Unhandled rejection Error: invalid argument at pathToArrayI believe it's coming from
It should be:
path: path.join( __dirname, '/wwwroot/bundles' )JanEggers commentedon Oct 27, 2016
the configuration i have is correct. it is working with webpack devserver or aspnet-webpack < 1.0.19
the error is thrown at a row that validates a regex that does not accept \ and i dont have \ in my config so it must be some internal path stuff of aspnet-webpack
SteveSandersonMS commentedon Oct 27, 2016
There was an issue in path handling on version 1.0.19, which was since fixed in 1.0.20. Can you let us know whether you still encounter the problem in the latest version of aspnet-webpack (1.0.21)?
JanEggers commentedon Oct 27, 2016
yep 1.0.21 gives the same error. any advices how i could isoate the source of the error?
SteveSandersonMS commentedon Oct 28, 2016
I know you've mentioned that your webpack config is correct and works with webpack devserver, but it really doesn't look right. I suspect it might have only worked in the past because you're using an older version of
webpack-dev-middleware(i.e., 1.8.1 or below) that allows some things to work almost by mistake even though they are ambiguous. Since version 1.8.2/1.8.3,webpack-dev-middlewareintroduces a stronger check thatoutput.pathis absolute, accounting for Win/*nix path differences.Your specification
path: '/wwwroot/bundles'is an absolute path in Linux terms (and it's almost certainly not where you want to write your output), but doesn't have any clear meaning on a Windows system (and I see you are running Windows). For your webpack config to be correct as far aswebpack-dev-middlewareversion 1.8.2+ is concerned, you absolutely must specify an absolute path foroutput.path, or you'll get this error:Once you fix that aspect of your config, I suspect the error will go away. Roughly as @MarkPieszak mentioned, you can fix it by changing the config to:
To avoid this problem coming up for others in the future, I'm changing
aspnet-webpackto take a dependency onwebpack-dev-middleware1.8.3+ (previously it only required 1.6.1+), so there should be a clearer error message if you don't supply an absolute path foroutput.path.Please let us know if this resolves the issue for you!
JanEggers commentedon Oct 28, 2016
now that is interesting:
if i change the ouput.path and stay on version 1.0.18 it works.
but if i update to 1.0.21 i get the following error:
Microsoft.AspNetCore.NodeServices: Error: Error: ENOENT: no such file or directory, open 'D:\Repositories\Maintenance Web App\src\Maintenance.Web\wwwroot\bundles\assets\summarizer.7d4eb4e532b05499591f6aa06632e072.png'
at Error (native)
the path is correct / as it was in version 1.0.18
the file is not present (but it wasnt either with 1.0.18)
any ideas?
SteveSandersonMS commentedon Oct 28, 2016
I tried to reproduce your issue (using
loader: 'file?name=assets/[name].[hash].[ext]'for an image, and running it on Windows from a directory where one of the parents has a space in its name) but no such problem occurred. It worked fine.So I'm afraid I don't know what's going on with your setup. Also I don't know how to interpret some of your statements:
As in, you've fixed it so it doesn't have the leading slash? Or you've left the leading slash in place? It should not have a leading slash, as described earlier.
So was it working on 1.0.18 or not? I'm not sure how it could be working if the .png file was not present.
In order to investigate the further, I'd need to be able to reproduce the issue. If you're able to supply a minimal repro case (as in, starting with something like the Angular2Spa template, how to modify it to trigger the issue you've described) then I'll certainly be able to track it down.
JanEggers commentedon Oct 28, 2016
it was working but it seems no files where written to disk and only served from in memory
ill try to create a repro next week. have a nice weekend.
JanEggers commentedon Oct 31, 2016
hi there i didnt create a repro but i found the error by adding logging.
here is the modified copy version:
if a pr is wellcome i'll add one
SteveSandersonMS commentedon Oct 31, 2016
Thanks @JanEggers for tracking this down! I've now published
aspnet-webpackversion 1.0.23 which includes your fix.