nuxt: [nuxt] [request error] Directory import '...\.output\server\node_modules\@apollo\client\core' is not supported resolving ES modul es imported from ...\.output\server\chunks\server.mjs Did you mean to import @apollo/client/core/index.js?
Environment
Nuxt CLI v3.0.0-rc.3 14:35:02 RootDir: C:\Users\Ilya\Desktop\nuxt-app 14:35:06 Nuxt project info: 14:35:06
- Operating System:
Windows_NT - Node Version:
v16.15.0 - Nuxt Version:
3.0.0-rc.3 - Package Manager:
yarn@1.22.15 - Builder:
vite - User Config:
ssr - Runtime Modules:
- - Build Modules:
-
Reproduction
https://github.com/loremru/bug-reproduction
yarn build yarn start
Describe the bug
Apollo Client doesnt work in a BUILD with SSR: true. In DEV or SSR off its ok.
[nuxt] [request error] Directory import ‘….output\server\node_modules@apollo\client\core’ is not supported resolving ES modul es imported from ….output\server\chunks\server.mjs Did you mean to import @apollo/client/core/index.js?

yarn build yarn start
Additional context
No response
Logs
No response
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
Hello everybody! You need to transpile all the modules which use
@apollo/client. So if you use@vue/apollo-composablethen you need to add this module to transpile section either.Also you can transpile the modules only during building:
UPDATE: See https://github.com/nuxt/nuxt.js/issues/13995 for the solution
Apollo should work fine on both, server and client side. But it likely must be transpiled.
Add
'@apollo/client'and'ts-invariant/process'to yourtranspilearray in the nuxt.config.js/.tsexample:
this module <0.1.0 works fine with nuxt3 but not nuxt@rc 0.1.1 works for nuxt@rc now
@manniL It only works in a dev mode, but not in build. I think there is a problem with nuxt. And I already use
ssrMode: true