Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

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

Closed
Jamie-Clayton opened this issue Apr 10, 2017 · 2 comments
Closed

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

Jamie-Clayton opened this issue Apr 10, 2017 · 2 comments

Comments

@Jamie-Clayton
Copy link

Jamie-Clayton commented Apr 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

`

@SteveSandersonMS
Copy link
Member

Your version of Node is too old - please update to a newer version that supports const by default.

@Jamie-Clayton
Copy link
Author

Jamie-Clayton commented Apr 11, 2017

@SteveSanderson thanks, looks like the windows path variable was not correctly updated in the node 6 or 7 x64 installation. Nodejs discussion.
After updating the path to the correct location
node -v v6.10.2
The solution then works as expected. Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants