2

I'm creating a new project with this tutorial:

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

Next some resolved issues, I have now a complete project with all dependencies installed but when I launch the project with 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 don't know which step I failed so if someone already did it.

1 Answer 1

2

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

The const and let are part of ECMAScript 2015 (a.k.a. ES6 and Harmony), and was not enabled by default in Node.js 0.10 or 0.12. Since Node.js 4.x, “All shipping [ES2015] features, which V8 considers stable, are turned on by default on Node.js and do NOT require any kind of runtime flag.”.

So by upgrading to Node.js 4.x or newer the error should disappear.

https://stackoverflow.com/a/23151062/5082427

Update

You can check the installed version of node by executing node -v in the command-line. If this command outputs an older version than the one you have installed, check the PATH environment variable to ensure you don't have multiple node installations.

Sign up to request clarification or add additional context in comments.

7 Comments

Im using Node 6
@Elykx are you sure? Could you type "node -v" in the command-line and comment the results?
Thats what i get node -v v0.12.2
So, you're not using Node 6. You're using Node 0.12.2.
That's peculiar, it seems you have multiple versions of node installed then. Try checking your PATH environment variable and see if there are multiple paths to a node installation in there.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.