Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webpack-cli ERROR:Unexpected token = #176

Closed
cleverlion opened this issue Sep 6, 2021 · 6 comments
Closed

webpack-cli ERROR:Unexpected token = #176

cleverlion opened this issue Sep 6, 2021 · 6 comments

Comments

@cleverlion
Copy link

When starting the project,webpack-cli throws an error:
SyntaxError: Unexpected token =

The configuration in the .babelrc file is:
{ "presets": [ ["env", { "modules": false }], "stage-2", "es2015" ], "plugins": ["transform-runtime"], "comments": false }

`[webpack-cli] D:\lifeRestart\my-project\node_modules\webpack-dev-server\lib\servers\WebsocketServer.js:10
static heartbeatInterval = 1000;
^

SyntaxError: Unexpected token =
at new Script (vm.js:83:7)
at NativeCompileCache._moduleCompile (D:\lifeRestart\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:240:18)
at Module._compile (D:\lifeRestart\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:184:36)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (D:\lifeRestart\my-project\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Server.getServerTransport (D:\lifeRestart\my-project\node_modules\webpack-dev-server\lib\Server.js:982:28)`

@jayzun
Copy link

jayzun commented Sep 6, 2021

webpack-dev-server使用了新的定义class成员的语法,你可以升级你的node版本试试

@cleverlion
Copy link
Author

webpack-dev-server使用了新的定义class成员的语法,你可以升级你的node版本试试

好的谢谢

@g1un
Copy link

g1un commented Sep 7, 2021

Just translated @jayzun answer, it helped me.
webpack-dev-server uses a new syntax to define class members,you can upgrade your node version to try

@jadeshenker
Copy link

@g1un what version did you need to update to?

@rubangarmon
Copy link

Same problem. I'm using webpack serve --config ./webpack.config.ts

@joergkrause
Copy link

Definitely upgrading NodeJs helps. The static variables syntax is available in Node 6, but the static class variable that's used here is available in Node 12.6. Going to the latest LTS is recommended to solve the issue.

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

No branches or pull requests

6 participants