Skip to content

vue-cli init with some unknown error : Uncaught SyntaxError: Use of const in strict mode. #1140

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

Closed
Hillkinsh opened this issue Dec 4, 2017 · 12 comments

Comments

@Hillkinsh
Copy link

when I initial a new project, I used commands as follows:
vue init webpack my-pro
cd my-pro/
npm install
npm run dev

then, it shows :
" DONE Compiled successfully in 5653ms

Your application is running here: http://localhost:8080" in command line",

but when I open chrome and address in localhost:8080,
there is an error:
"Uncaught SyntaxError: Use of const in strict mode. "

so, how could I solve it?

ps: node version v8.8.0

@afontcu
Copy link
Contributor

afontcu commented Dec 4, 2017

Hm, that's weird. Could you just double check that you are using node 8.8.0? As long as you are on node greater than v4, you should be good to go.

Could you just describe your environment a little more? node, npm versions, OS, etc.
Are you running your app from the OS cli or using some IDE?

@Hillkinsh
Copy link
Author

Hillkinsh commented Dec 4, 2017

OK, my OS is ubuntu 12.04. node v8.8.0 npm 5.4.2, vue 2.9.2.
No one had such a problem before. So confused!!!!!

@LinusBorg
Copy link
Contributor

I can't reproduce this (I'm on OS X though).

Does the error tell you where that syntax error is happening?

@Hillkinsh
Copy link
Author

Hillkinsh commented Dec 5, 2017

Well, I use command "vue init browserify my-bro", and everything's ok.

I'll show you everything that happend on me.

Ops, why can't I paste any picture here?

I show it in words.

1,vue init webpack my-pro2
cd my-pro2
npm install
npm run dev
and in command line it shows:

    DONE  Compiled successfully in 15155ms                                 09:50:43

     I  Your application is running here: http://localhost:8080

2,my chrome address in http://localhost:8080/ and show nothing.

3, F12, and in console :

     Uncaught SyntaxError: Use of const in strict mode. localhost/:6

There are all the things I know.

@simll
Copy link

simll commented Dec 12, 2017

I think I got the same error, there are something helpful for me:

webpack/webpack-dev-server#1105
https://github.com/mrdulin/blog/issues/35

there are two way to resolved it:

  1. use webpack-dev-server version 2.7.1;
  2. set babel-loader include webpack-dev-server/client/index.js;

I resolve it like that:
set ./build/webpack.base.config.js

{
  test: /\.js$/,
  loader: 'babel-loader',
  include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},

@LinusBorg
Copy link
Contributor

Hm, that's a weird choice by the maintainers.

I think we should add this workaround to the template.

Thanks for getting to the bottom of this.

@LinusBorg
Copy link
Contributor

I just pushed that fix to the develop branch, anyone interested can test it out with

vue init webpack#develop

@Hillkinsh
Copy link
Author

Hillkinsh commented Dec 21, 2017

I update my OS to Ubuntu 14.04. (before is 12.04.) and then everything is OK.

@XavierShi
Copy link

Thank you very much!

frandiox pushed a commit to OnsenUI/vue-cordova-webpack that referenced this issue Dec 25, 2017
julon pushed a commit to julon/vue-cli-template-github-pages that referenced this issue Dec 29, 2017
LinusBorg added a commit that referenced this issue Dec 31, 2017
* develop:
  bump template version
  fix bug with #1202
  Make CSS sourcemaps on by default
  Ensure page reloads in history mode serve index.html
  use old sourcemap option
  Add postcss-url to match postcss-import (#1115)
  Change engine>node{4 => 6} for template (#1206)
  Fix static file serving for publicPath != `/` (fix#1176) (#1180)
  Load, render template version using helper (#1202)
  fix typo in a comment (#1183)
  fix #1140
slipkinem pushed a commit to slipkinem/webpack-ts that referenced this issue Jan 9, 2018
@Olivia2008
Copy link

I met the same problem
and i did it like that
1、use webpack-dev-server version 2.7.1;
2、set babel-loader include webpack-dev-server/client/index.js;

but it did not work, i dont know how to resolve it
who could do me a favor?

@yjwSurCode
Copy link

I think I got the same error, there are something helpful for me:

webpack/webpack-dev-server#1105
mrdulin/blog#35

there are two way to resolved it:

  1. use webpack-dev-server version 2.7.1;
  2. set babel-loader include webpack-dev-server/client/index.js;

I resolve it like that:
set ./build/webpack.base.config.js

{
  test: /\.js$/,
  loader: 'babel-loader',
  include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},

我这边设置 没有用啊

@hoelshen
Copy link

hoelshen commented Mar 7, 2021

I think I got the same error, there are something helpful for me:
webpack/webpack-dev-server#1105
mrdulin/blog#35
there are two way to resolved it:

  1. use webpack-dev-server version 2.7.1;
  2. set babel-loader include webpack-dev-server/client/index.js;

I resolve it like that:
set ./build/webpack.base.config.js

{
  test: /\.js$/,
  loader: 'babel-loader',
  include: [resolve('src'), resolve('test'), resolve('node_modules/webpack-dev-server/client')]
},

我这边设置 没有用啊

我也是不生效
image

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

No branches or pull requests

8 participants