Skip to content
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

[Bug] Named export 'setOptions' not found. // Nuxt 3 #285

Open
2 tasks done
simonmaass opened this issue Oct 20, 2023 · 3 comments
Open
2 tasks done

[Bug] Named export 'setOptions' not found. // Nuxt 3 #285

simonmaass opened this issue Oct 20, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@simonmaass
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Have you updated Vue FilePond, FilePond, and all plugins?

  • I have updated FilePond and its plugins

Describe the bug

I am using nuxt 3 with the following import:

import VueFilePond, { setOptions } from 'vue-filepond'

When accessing the page client side everything works but when reloading the page with ssr i get the following error:

import { setOptions } from 'vue-filepond';
         ^^^^^^^^^^
SyntaxError: Named export 'setOptions' not found. The requested module 'vue-filepond' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'vue-filepond';
const { setOptions } = pkg;
image

Reproduction

When running "yarn dev" the error does not occur.. but when running yarn build and yarn start in SSR i get the error

Environment

- Device: Lenovo Thinkpad
- OS: Windows 10
- Browser: Version 118.0.5993.72 (Offizieller Build) (64-Bit)
- Vue version: 3.3.4
- Nuxt version: 3.7
@simonmaass simonmaass added the bug Something isn't working label Oct 20, 2023
@simonmaass
Copy link
Author

I was able to get this working in nuxt SSR mode via this https://github.com/cyco130/vite-plugin-cjs-interop

@soylomass
Copy link

I was able to get this working in nuxt SSR mode via this https://github.com/cyco130/vite-plugin-cjs-interop

Thanks, this worked.

After installing it, you have to add this block to nuxt.config.ts:

vite: {
  plugins: [
    cjsInterop({
      // List of CJS dependencies that require interop
      dependencies: ["vue-filepond"],
    }),
  ],
},

@simonmaass
Copy link
Author

you are also able to get it to work without the plugin with this setting:

build: {
    transpile: ['vue-filepond']
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants