This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
"Call to Node module failed with error: TypeError: Cannot read property 'substring' of undefined" after upgrading to aspnet-webpack 1.0.20 npm packge. #376
Copy link
Copy link
Closed
Description
Switching to a new PC, npm install resolved to newer npm version of aspnet-webpack and now WebpackDevMiddleware fails to start:
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AggregateException: One or more errors occurred. (Call to Node module failed with error: TypeError: Cannot read property 'substring' of undefined
at firstIndexOfStringStartingWith (E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:192:22)
at E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:26:22
at Array.forEach (native)
at attachWebpackDevMiddleware (E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:20:51)
at E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:162:21
at Array.forEach (native)
at Server.<anonymous> (E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:145:32)
at Server.g (events.js:291:16)
at emitNone (events.js:86:13)
at Server.emit (events.js:185:7)) ---> System.Exception: Call to Node module failed with error: TypeError: Cannot read property 'substring' of undefined
at firstIndexOfStringStartingWith (E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:192:22)
at E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:26:22
at Array.forEach (native)
at attachWebpackDevMiddleware (E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:20:51)
at E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:162:21
at Array.forEach (native)
at Server.<anonymous> (E:\P\Fantasy\src\Fantasy\node_modules\aspnet-webpack\WebpackDevMiddleware.js:145:32)
at Server.g (events.js:291:16)
at emitNone (events.js:86:13)
at Server.emit (events.js:185:7)
at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.<InvokeExportAsync>d__7`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.<InvokeExportAsync>d__13`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.<InvokeExportWithPossibleRetryAsync>d__10`1.MoveNext()
--- End of inner exception stack trace ---
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
at Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options)
at Fantasy.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.AspNetCore.Hosting.Internal.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()
at Microsoft.AspNetCore.Hosting.WebHostBuilder.Build()
at Fantasy.Program.Initialize(String[] args)
at Fantasy.Program.Main(String[] args)
Comparing with the old computer, I could isolate the issue to upgrading aspnet-webpack@1.0.16 to aspnet-webpack@1.0.20. The upgrade was done automatically because my package.json looks like this:
(...)
"devDependencies": {
"aspnet-webpack": "^1.0.16", --> auto upgrade minor
"babel-core": "^6.5.2",
"babel-loader": "^6.2.3",
"babel-preset-es2015": "^6.5.0",
"css-loader": "^0.23.1",
"extendify": "^1.0.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.9.0",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "1.13.2",
"webpack-hot-middleware": "2.13.0"
}
Just in case, this is my ´project.json´:
{
"dependencies": {
"Microsoft.AspNetCore.Authentication.Cookies": "1.0.0",
"Microsoft.AspNetCore.Authentication.Facebook": "1.0.0",
"Microsoft.AspNetCore.Diagnostics": "1.0.0",
"Microsoft.AspNetCore.Identity": "1.0.0",
"Microsoft.AspNetCore.Identity.EntityFrameworkCore": "1.0.0",
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Razor.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
"Microsoft.AspNetCore.Server.Kestrel.Https": "1.0.1",
"Microsoft.AspNetCore.SpaServices": "1.0.0-*", --> The latest I see in intelisense is "1.0.0-beta-000019"
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.EntityFrameworkCore.InMemory": "1.0.1",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0",
"Microsoft.EntityFrameworkCore.SqlServer.Design": {
"version": "1.0.0",
"type": "build"
},
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
"Microsoft.Extensions.Configuration.Json": "1.0.0",
"Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
"Microsoft.Extensions.Logging": "1.0.0",
"Microsoft.Extensions.Logging.Console": "1.0.0",
"Microsoft.Extensions.Logging.Debug": "1.0.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"System.Security.Cryptography.X509Certificates": "4.1.0",
"System.Xml.XmlSerializer": "4.0.11"
},
"tools": {
"Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
"Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final",
"Microsoft.Extensions.SecretManager.Tools": "1.0.0-preview2-final",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
},
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true
},
"runtimeOptions": {
"configProperties": {
"System.GC.Server": true
}
}
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
(...)
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true,
});
Using Win10+VS2015 Update3.
My build is working fine now after rollbacking aspnet-webpack 1.0.16, but still raising this issue to find a root cause.
Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
SteveSandersonMS commentedon Oct 17, 2016
Thanks for reporting it.
I'm not certain how your Webpack config triggers that error (perhaps you have a
nullorundefinedentry in your entrypoints array), but in any case, I've publishedaspnet-webpackversion 1.0.21 that contains an extra check for such a scenario.Make aspnet-webpack resilient against Webpack configs with nonstring …