Webpackmiddleware - SyntaxError: Use of const in strict mode #842

Closed
opened 2025-08-09 17:17:53 +00:00 by fergalmoran · 0 comments
Owner

Originally created by @Jamie-Clayton on 4/10/2017

Following the basic steps for VS 2017 + .net core + SPA + angular 2 in .net core + SPA + Angular 2

CLI
`

dotnet new --install Microsoft.AspNetCore.SpaTemplates::*
dotnet new angular

`

Open VS 2017 and the project that was created.
Run the application via F5 and the following exception gets generated against startup.cs on the webpack middleware

app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true });

Exception

Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'.
Error was: C:\Users\jamie\Documents\SourceCode\spike-angular-on-core\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. (C:\Users\jamie\Documents\SourceCode\spike-angular-on-core\node_modules\aspnet-webpack\WebpackDevMiddleware.js:4:15)

From what I can understand of the problem node_modules\webpack\lib\webpack.js is using ES6 definitions while the Typescript behind node_modules\aspnet-webpack\WebpackDevMiddleware.js is using ES2015. How does a developer resolve this?

Environment

Windows 10 Pro 15063.13
VS 2017 Pro.
`

dotnet --version
1.0.2

node --version
v0.12.2

npm --version
2.7.4

`

*Originally created by @Jamie-Clayton on 4/10/2017* Following the basic steps for VS 2017 + .net core + SPA + angular 2 in [.net core + SPA + Angular 2](https://jonhilton.net/2017/02/21/create-a-vs2017-angular-2-and-net-core-site-using-the-command-line/) **CLI** ` dotnet new --install Microsoft.AspNetCore.SpaTemplates::* dotnet new angular ` Open VS 2017 and the project that was created. Run the application via F5 and the following exception gets generated against startup.cs on the webpack middleware ` app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); ` # Exception > Exception: Call to Node module failed with error: Webpack dev middleware failed because of an error while loading 'aspnet-webpack'. > Error was: C:\Users\jamie\Documents\SourceCode\spike-angular-on-core\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:\Users\jamie\Documents\SourceCode\spike-angular-on-core\node_modules\aspnet-webpack\WebpackDevMiddleware.js:4:15) From what I can understand of the problem **node_modules\webpack\lib\webpack.js** is using ES6 definitions while the Typescript behind node_modules\aspnet-webpack\WebpackDevMiddleware.js is using ES2015. How does a developer resolve this? ## Environment Windows 10 Pro 15063.13 VS 2017 Pro. ` dotnet --version 1.0.2 node --version v0.12.2 npm --version 2.7.4 `
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/JavaScriptServices#842
No description provided.