Vue-instantsearch: Unexpected Token Export when using nuxt

Created on 25 Feb 2019  路  12Comments  路  Source: algolia/vue-instantsearch

Bug 馃悶

What is the current behavior?

From a fresh installation on nuxt, an "Unexpected token export" error is thrown immediately when adding the vue-instantsearch plugin to the nuxt configuration file.

Make a sandbox with the current behavior

https://codesandbox.io/s/github/TateB/nuxt-error/tree/master/

What is the expected behavior?

The plugin should be able to be initialised without any errors. It happens all the time.

What is the version you are using?

Version 2.0.0

Most helpful comment

@TateB, you need to set the dependencies to be transpiled correctly:

https://github.com/algolia/vue-instantsearch/blob/afc7d76c7c47b562948e10dd023049175ee35d6b/examples/nuxt/nuxt.config.js#L4-L6

You're correct that this is missing in the docs, seems like I forgot to paste it in from the draft version.

All 12 comments

@TateB, you need to set the dependencies to be transpiled correctly:

https://github.com/algolia/vue-instantsearch/blob/afc7d76c7c47b562948e10dd023049175ee35d6b/examples/nuxt/nuxt.config.js#L4-L6

You're correct that this is missing in the docs, seems like I forgot to paste it in from the draft version.

I just made a patch for this in the docs. The docs team are currently doing a big refactor however, so it might not immediately be merged.

Have a nice day!

@TateB, you need to set the dependencies to be transpiled correctly:

vue-instantsearch/examples/nuxt/nuxt.config.js

Lines 4 to 6 in afc7d76

build: {
transpile: ['vue-instantsearch', 'instantsearch.js/es'],
},
You're correct that this is missing in the docs, seems like I forgot to paste it in from the draft version.

many thanks.

It's July 2020 and I still had to add this fix to get a fresh install working.

A fresh installation with no dependencies giving this error.

A fresh installation with no dependencies giving this error.

fix: build: {
transpile: [ ]
}

I also just ran into this issue... :/

Sorry, that's an issue on Nuxt's side, there's nothing wrong with transpiling, but there's no way for us to tell Nuxt it _should_ be added from our side

@TateB, you need to set the dependencies to be transpiled correctly:

https://github.com/algolia/vue-instantsearch/blob/afc7d76c7c47b562948e10dd023049175ee35d6b/examples/nuxt/nuxt.config.js#L4-L6

You're correct that this is missing in the docs, seems like I forgot to paste it in from the draft version.

after adding this line, 'npm run dev' works fine, untill I run 'npm run build' again. After that, error again shows up on 'npm run dev'. Any ideas? Anyone else getting same issue?

hm, I don't have that on our demos @yog3sha, maybe try removing the cache directories? If you have a GitHub repo with reproduction I can look into it

@yog3sha
I have exactly the same problem. Did you find a solution?

just add ssr: false for plugin

{ src: '@/plugins/components.js' ,ssr: false},

add this code to build nuxt config

build: {
       transpile: ['@stylelib']
},
Was this page helpful?
0 / 5 - 0 ratings

Related issues

rayrutjes picture rayrutjes  路  3Comments

jackwkinsey picture jackwkinsey  路  4Comments

samouss picture samouss  路  3Comments

intrepidws picture intrepidws  路  5Comments

abattenburg picture abattenburg  路  4Comments