Composition-api: fix: Unexpected token {

Created on 8 Sep 2020  路  7Comments  路  Source: nuxt-community/composition-api

馃悰 The bug
I get this screen on a page visit, when I import anything from @nuxtjs/composition-api.

I'll do my best to provide a reproduction repo soon.

Screenshot 2020-09-08 at 17 28 42

needs-repro

Most helpful comment

@MartinMalinda This error normally indicates you haven't added @nuxtjs/composition-api to your buildModules array.

All 7 comments

This appears during build and it might be connected:

ERROR  Failed to compile with 3 errors

This dependency was not found:

* fs in ./node_modules/fs-extra/lib/index.js, ./node_modules/graceful-fs/graceful-fs.js and 1 other

Can you share a reproduction link / repro?

@MartinMalinda This error normally indicates you haven't added @nuxtjs/composition-api to your buildModules array.

@MartinMalinda, I second @danielroe's answer. Solved it for me regarding the fs error.

@MartinMalinda I'm closing this but do let me know if you can reproduce this error with the module in your buildModules array.

@danielroe hi
Added to buildModules but still getting error:

 WARN  in ./node_modules/@nuxt/utils/dist/utils.js                                                                                                                                         friendly-errors 22:15:48

Critical dependency: the request of a dependency is an expression                                                                                                                          friendly-errors 22:15:48
                                                                                                                                                                                           friendly-errors 22:15:48

 ERROR  Failed to compile with 3 errors                                                                                                                                                    friendly-errors 22:15:48

This dependency was not found:                                                                                                                                                             friendly-errors 22:15:48
                                                                                                                                                                                           friendly-errors 22:15:48
* fs in ./node_modules/fs-extra/lib/index.js, ./node_modules/graceful-fs/graceful-fs.js and 1 other                                                                                        friendly-errors 22:15:48
                                                                                                                                                                                           friendly-errors 22:15:48
To install it, you can run: npm install --save fs

I use spa (ssr: false) mode

"nuxt": "^2.14.6"
"@nuxtjs/composition-api": "^0.13.0"

UPD:
Sorry, my fault
I had and alias in webpackConfig:

'@vue/composition-api': require.resolve('@nuxtjs/composition-api')

Wanted to get a backward compatibility with @vue/composition-api

@crutch12 I think you could actually do that, but amend to

'@vue/composition-api': require.resolve('@nuxtjs/composition-api/lib/entrypoint.js')
Was this page helpful?
0 / 5 - 0 ratings