"...mapActions" Unexpected token
See original GitHub issueI have a Vue component that is trying to use:
Register.vue
<script>
import { mapActions } from 'vuex'
// ...
methods: {
// ...
...mapActions({
storeDetails: 'updateRegisterDetails'
})
}
// ...
</script>
However, when I run yarn run dev
I get the following output:
ERROR Failed to compile with 1 errors
error in ./resources/assets/js/auth/components/Register.vue
SyntaxError: Unexpected token (54:8)
52 | this.$router.push('/register/payment')
53 | },
> 54 | ...mapActions({
| ^
55 | storeDetails: 'updateRegisterDetails'
56 | })
57 | }
@ ./resources/assets/js/auth/components/Register.vue 3:2-131
@ ./resources/assets/js/auth/routes.js
@ ./resources/assets/js/auth.js
@ multi ./resources/assets/js/auth.js
Asset Size Chunks Chunk Names
/js/auth.51d4dde1906cc579aad7.js 2.22 MB 0 [emitted] [big] /js/auth
/js/app.ecd4f96976599fef6161.js 2.18 MB 1 [emitted] [big] /js/app
/css/app.8598eae19ab06ab7bf2b.css 177 kB 1 [emitted] /js/app
/js/auth.51d4dde1906cc579aad7.js.map 2.74 MB 0 [emitted] /js/auth
/js/app.ecd4f96976599fef6161.js.map 2.68 MB 1 [emitted] /js/app
/css/app.8598eae19ab06ab7bf2b.css.map 10.3 kB 1 [emitted] /js/app
mix-manifest.json 344 bytes [emitted]
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Any idea what I should be doing here? I don’t see anything documented in regards to configuring anything additional for Vue.
webpack.mix.js
const { mix } = require('laravel-mix');
if (process.env.NODE_ENV == 'production') {
mix.disableNotifications();
}
mix.webpackConfig({
devtool: 'cheap-source-map'
});
mix.js('resources/assets/js/app.js', 'public/js')
.js('resources/assets/js/auth.js', 'public/js')
.sass('resources/assets/sass/app.scss', 'public/css')
.version(['css/app.css', 'js/app.js', 'js/auth.js']);
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
"...mapActions" Unexpected token · Issue #345 · laravel-mix ...
I have a Vue component that is trying to use: Register.vue However, when I run yarn run dev I...
Read more >Unexpected token when I trying to use ...mapGetters or ...
I try to follow the nuxt guide, but I can't find nothing about how to use mapGetters. This is the shell error: Syntax...
Read more >'Unexpected token' when using mapState - Vue Forum
My babel config is set to es2015 so I guess that's why the spread operator doesn't work, but that doesn't explain my second...
Read more >Vuex : error ...mapActions ...mapGetters - Laracasts
I have an error. Copy Code error in ./resources/assets/js/components/Searchbar.vue Syntax Error: Unexpected token (102:8). from this code. Copy Code
Read more >vuex2中使用mapMutations/mapActions报错解决方法 ... - 博客园
但是在借助babel编译转换时发生了报错: BabelLoaderError: SyntaxError: Unexpected token 。 解决方案在vuex的repo issues中有人提过这样的问题,后来是 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Running the following:
Then creating a
.babelrc
in the root of our project with:Resolved this.
Don’t have to install babel-preset-stage-2, simply add Object rest spread transform babel plugin.
npm install --save-dev babel-plugin-transform-object-rest-spread
in .
babelrc
, add the following:{ "plugins": ["transform-object-rest-spread"] }