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

@vue/apollo-ssr doesn't work in SSR mode #1524

Closed
lermontex opened this issue Dec 21, 2023 · 0 comments · Fixed by Shoutzor/frontend#141 or Shoutzor/frontend#146
Closed

@vue/apollo-ssr doesn't work in SSR mode #1524

lermontex opened this issue Dec 21, 2023 · 0 comments · Fixed by Shoutzor/frontend#141 or Shoutzor/frontend#146

Comments

@lermontex
Copy link

Describe the bug

I'm using Vue 3 + Vite 4/5 + NodeJS 20

When trying to use the @vue/apollo-ssr package in SSR mode, I get the following error:

node-1   | import { exportStates } from "@vue/apollo-ssr";
node-1   |          ^^^^^^^^^^^^
node-1   | SyntaxError: Named export 'exportStates' not found. The requested module '@vue/apollo-ssr' is a CommonJS module, which may not support all module.exports as named exports.
node-1   | CommonJS modules can always be imported via the default export, for example using:
node-1   |
node-1   | import pkg from '@vue/apollo-ssr';
node-1   | const { exportStates } = pkg;
node-1   |
node-1   |     at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
node-1   |     at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
node-1   |     at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
node-1   |     at async file:///srv/app/server.js:87:9

I tried applying the patch and adding type: 'module' to the package.json file of the @vue/apollo-ssr package - it works. It seems the error is due to an incorrect configuration of the package.json file

To Reproduce
Use @vue/apollo-ssr + Vite in SSR mode

Versions
vue: 3.3.0
@apollo/client: 3.8.* / 3.9.0-beta.1
@vue/apollo-composable: 4.0.0-beta.12
@vue/apollo-ssr: 4.0.0-beta.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment