AspNetCore + Angular 2: WebpackDevMiddleware Error with New Project

I am creating a new project using this tutorial:

https://blogs.msdn.microsoft.com/webdev/2017/02/14/building-single-page-applications-on-asp-net-core-with-javascriptservices/

Further some resolved problems, now I have a complete project with all the dependencies installed, but when I start the project using IIS, I have this error.

L'exception System.AggregateException s'est produite HResult=0x80131500 Message=One or more errors occurred. Source=<Impossible d'évaluer la source de l'exception> Arborescence des appels de procédure : 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 Test.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) in C:\VS2017\Project\Test\Startup.cs:line 44 Exception interne 1 : Exception : Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. Error was: C:\VS2017\Project\Test\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) at require (module.js:384:17) at Object.<anonymous> (C:\VS2017\Project\Test\node_modules\aspnet-webpack\WebpackDevMiddleware.js:4:15) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) Current directory is: C:\VS2017\Project\Test 

I do not know which step I failed if someone had already done so.

+1
source share
1 answer

This is because the aspnet-webpack node package requires a newer version of node .

The const and let elements are part of ECMAScript 2015 (aka ES6 and Harmony) and were not included by default in Node.js 0.10 or 0.12. Because Node.js 4.x, "All delivery functions [ES2015] that V8 considers stable are included by default in Node.js and DO NOT require any runtime flag."

So, upgrading to Node.js 4.x or later, the error should go away.

fooobar.com/questions/32469 / ...

Update

You can verify the installed version of node by running node -v on the command line. If this command displays an older version than the one you set, check the PATH environment variable to make sure you don't have multiple node installations.

+2
source

Source: https://habr.com/ru/post/1272850/


All Articles