Skip to content

vue server can not use async/await #2648

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
githoniel opened this issue Sep 29, 2018 · 4 comments
Closed

vue server can not use async/await #2648

githoniel opened this issue Sep 29, 2018 · 4 comments

Comments

@githoniel
Copy link
Contributor

githoniel commented Sep 29, 2018

Version

3.0.4

Node and OS info

Node 8.11.4/ Npm 6.4.1 / Windows 10

Steps to reproduce

npm i @vue/cli @vue/cli-service-global -g

I got warning below

npm WARN [email protected] requires a peer of @babel/core@^7.0.0 but none is installed. You must install peer dependencies yourself.

then create a vue file index.vue

<template>
<div></div>
</template>
<script>
export default {
    methods: {
        async test(){}
    }
}
</script>

atfer run vue serve index.vue get compile error

 ERROR  Failed to compile with 1 errors                                                                     
This dependency was not found:

* regenerator-runtime/runtime in C:/Users/xxxx/AppData/Roaming/npm/node_modules/@vue/cli-service-global/node_modules/babel-loader/lib??ref--12-0!C:/Users/xxxx/AppData/Roaming/npm/node_modules/@vue/cli-service-global/node_modules/cache-loader/dist/cjs.js??ref--0-0!C:/Users/xxxx/AppData/Roaming/npm/node_modules/@vue/cli-service-global/node_modules/vue-loader/lib??vue-loader-options!./src/index.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save regenerator-runtime/runtime   

What is expected?

vue serve support async/await

What is actually happening?

failed to compile

@LinusBorg
Copy link
Member

  1. I don't get such a warning for babel-loader, just updated my cli and cli-service-global installs to 3.0.4

  2. Your example code is wrong, this is not valid javascript

export default () {

It should look like this:

export default {
  1. Once that it fixed, the app compiles fine for me, except for some eslint warnings:

image

So we could discuss if eslint-loader should really be used in this scenario, but the app works.

@LinusBorg LinusBorg added scope: cli-service serve scope: babel cannot reproduce We cannot reproduce the problem with the given information. More env information needed. labels Sep 29, 2018
@haoqunjiang
Copy link
Member

Reproduced on my machine.

@haoqunjiang haoqunjiang added bug and removed cannot reproduce We cannot reproduce the problem with the given information. More env information needed. labels Sep 29, 2018
@githoniel
Copy link
Contributor Author

githoniel commented Sep 29, 2018

@LinusBorg

  1. Sorry that wrong code was cause when I simplify my code, I have edit this issue.

Is it necessary to manualy install babel ? my npm global node_modules is below

tim 20180929205309

there is only @vue/[email protected] and @vue/[email protected] install in @VUE

I just uninstall them and reinstall this two.

@vue/cli seem all right.

npm i @vue/cli
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@vue\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})

but @vue/cli-service-global warn again like blew

C:\Users\xxxx>npm install -g @vue/cli-service-global
npm WARN deprecated [email protected]: Switch to the `bfj` package for fixes and new features!

> [email protected] install C:\Users\xxxx\AppData\Roaming\npm\node_modules\@vue\cli-service-global\node_modules\yorkie
> node bin/install.js

setting up Git hooks
trying to install from sub 'node_module' directory, skipping Git hooks installation
npm WARN [email protected] requires a peer of @babel/core@^7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\@vue\cli-service-global\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"ia32"})
  1. I think it is cause by 1.
    I temporarily fix this by add a babel.config.js in my project and install @vue/cli-plugin-babel for my project
/// babel.config.js
module.exports = {
    presets: [
        '@vue/app',
    ],
}
  1. It seem like you install 'eslint-loader' in you project as your pic show.
    In my first case, I just create a single file in a new folder, even without npm init.

@githoniel githoniel changed the title vue server can not use async/await vue server can not use async/await Sep 29, 2018
@HoweZhang
Copy link

So how do you use it? How did you configure it in babel.config.js @githoniel

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

4 participants