Closed navaneethramamoorthy closed 8 years ago
is it because am using ASP.NET Core 1.0, instead of ASP.NET CORE RC2.
No, that's not it. Everything here works with the 1.0 RTM. The only thing that even still mentions RC2 is my old blog post that I haven't got round to updating yet :)
aspnet webpack is installed properly
You're probably right, but just to be sure, is there a non-empty directory called aspnet-webpack
definitely on disk inside the node_modules
directory that is in the root of your project? If on Windows, be sure to check using Windows Explorer, and not just by looking at the list in Visual Studio - I'm not sure you can completely trust what VS shows in that list.
Assuming that directory is there, I wonder if you have a NODE_PATH
environment variable set on your machine. Ideally, you wouldn't (though if that does turn out to be the issue, I'd like to know more and find a good solution).
Finally, can you think of anything unusual about your Node installation? Is it perhaps really old, or installed in an unusual location, or you have multiple versions installed, or anything like that? Other people have reported similar issues in the past but I've never had any way of reproing any of them and would love to track down what people have in common when they see this error.
@navaneethramamoorthy I ran into this on one of my Windows machines. I was using nvm
(node version manager) and had multiple versions of Node installed.
What worked for me was:
%AppData%
/ roaming
delete any npm
or npm cache
folders therePATH
variable everything)npm i -g webpack
Then I tried the repo again and everything worked.
Thanks, I think I will try this suggestion, I am facing the same error. @MarkPieszak
I tried this but still to no avail @MarkPieszak
Fortunately after much agony I found a solution. By copy pasting a copy of node.exe to my website virtual directory (global folder) I am able to get it to work. I am not sure why this is the case, I would assume that since node is in my PATH I should not have to do this.
Glad you found a workaround.
FYI I think the underlying issue was just fixed in pull request #248, so this should no longer affect anyone (assuming they get NodeServices 1.0.0-beta-000010
or later).
In case anyone else sees this, I got the following error trying to run the published project in production mode after hard wiring the environment variable ASPNETCORE_ENVIRONMENT=Development on my dev machine.
Unhandled Exception: System.AggregateException: One or more errors occurred. (Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: Error: Cannot find module 'aspnet-webpack'
Without ASPNETCORE_ENVIRONMENT it works fine.
What about running in development on local IIS?
Currently, I have multiple projects that need to be run in development environment but i can not set the ASPNETCORE_ENVIRONMENT to development when publishing to local IIS.....
Is there a work around?
@martinfletcher You can set env variables for IIS processes as described here: https://www.iis.net/configreference/system.applicationhost/applicationpools/add/environmentvariables
@SteveSandersonMS Thanks, I had already done that, but still did not work.
I discovered (from the source code) that http binding is required for aspnet-webpack (hard coded localhost on http).
I take it this will now break if i have require https filters in place? Is there specific urls that i can exclude from this, or ideally a better way of not having to have http binding for my app?
I am getting this error after I upgraded a project to 2.0. Everything works fine except HotModule. Here is the full error
One or more errors occurred. (Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: C:\Development\Web\node_modules\webpack\lib\webpack.js:7
const Compiler = require("./Compiler");
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
Here is the code it errors on
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions
{
HotModuleReplacement = true
});
npm verison
{ 'web': '1.0.0-rc3',
npm: '2.7.4',
http_parser: '2.3',
modules: '14',
node: '0.12.2',
openssl: '1.0.1m',
uv: '1.4.2-node1',
v8: '3.28.73',
zlib: '1.2.8' }
@isaac2004 You're running a very old version of Node. You might need to update that. If that doesn't fix it, could you figure out what are the minimal steps to reproduce the issue based on a new project? Then we can investigate.
Upgrading Node seemed to fix the issue...
Upgrade Node to what? I'm using node v8.1.2 and am experiencing this problem. I have set ASPNETCORE_ENVIRONMENT=Development
globally on my Windows 10 machine.
When I attempt to use web.config to override the global system environment setting for ASPNETCORE_ENVIRONMENT
to force it from "Development" to "Production", it simply doesn't work; the application (ASP.NET Core running in IIS) still thinks the environment is "Development".
The only way I've found alter the environment setting is to alter the actual environment variables.
Fixed my issue by updating the NodeJS.
I ran into this problem when publishing on Azure because my app settings file was named: appsettingsDev.json but the ASPNETCORE_ENVIRONMENT variable in Azure (App Services/select the app/Application Settings) was set to "Development" (so it was looking for a file called "appsettingsDevelopment.json" not "appsettingsDev.json").
I changed the ASPNETCORE_ENVIRONMENT value to "Dev" and the problem went away.
Hi All, Is node_modules folder supposed to be on the server? I do not see this folder in my production site which works.
For some reason our latest deployment to test has causes this same issue.
HI Generator aspnetcore-spa project and tried to run in production mode. but gives below exception. aspnet webpack is installed properly. but still it is not loading the module. there is no change in package.json and project.json
it does not run in both production and development mode as well. is it because am using ASP.NET Core 1.0, instead of ASP.NET CORE RC2.
i want to check Server rendering feature in this project. how to achieve this?
thanks Navaneeth
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: To use webpack dev middleware, you must install the 'aspnet-webpack' NPM package.) ---> System.Exception: Call to Node module failed with error: To use webpack dev middleware, you must install the 'aspnet-webpack' NPM package. at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.d7d 12d__9
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.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.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 Ng2ServerRender.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 Ng2ServerRender.Program.Main(String[] args)