-
Notifications
You must be signed in to change notification settings - Fork 197
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
Failed to resolve import "@vue/apollo-composable" #444
Comments
Also: When opening a new issue, I get this message:
This one leads to a suspicous website... Could you please check this as well? :) |
I was digging a bit deeper and can say that this happens when using |
same here |
When I force add |
@Der-Alex @stygmate I've been unable to replicate this both locally as well as on StackBlitz, you can have a look at the basic reproduction here. Any additional information you can provide would be useful |
@Diizzayy Not sure what's happening... When I download the project from StackBlitz and install and run it, everything works. When I create a new project with I'm going to dig deeper... |
https://stackblitz.com/edit/nuxt-starter-fvrzqo This project was created with nodejs v18.12.1 and npm v8.19.2. So you will find differences inside the package-lock.json files. I guess it has something to do with the current npm version. After downgrading to node v15.14.0 (wich uses npm v7.7.6) I can run the project. |
in a fresh project using latest lts node, the package-lock.json file install apollo-composable in while in the repro project of @Diizzayy it's installed in |
Having the same problem but only when i make use of |
Also having the same problem using useMutation and useQuery. useAsyncQuery works fine.
If I import the composable manually like below, the error "Failed to resolve import "@vue/apollo-composable"" goes away However it presents another error; |
@ifusiontt The manually imported useQuery uses a different instance than the one defined in the module (the one being exposed in #imports). Therefore you would need to provide the apollo client yourself. For example (plugins/apollo.ts):
You can also use provideApolloClients if you need to use multiple clients. |
Hey @art-boer thanks for your help!. |
Indeed when I force installed @vue/apollo-composables, I now have access to useQuery. |
I am not quite sure how npm dependency resolution works, but I was abble to fix this issue simply by removing I am using
and my package.json looks like this
When I try to install one package after another, the error shows up. I belive it is because how dependecies are set in node@b3415af25c56:/app$ npm list vue
app@ /app
`-- @vue/[email protected]
+-- [email protected]
| `-- [email protected] deduped
`-- [email protected] When I install everything at once it looks like this node@b3415af25c56:/app$ npm list vue
app@ /app
+-- @nuxtjs/[email protected]
| `-- @vue/[email protected]
| +-- [email protected]
| | `-- [email protected] deduped
| `-- [email protected] deduped
`-- [email protected]
+-- @nuxt/[email protected]
| +-- @vitejs/[email protected]
| | `-- [email protected] deduped
| +-- @vitejs/[email protected]
| | `-- [email protected] deduped
| `-- [email protected] deduped
+-- @vueuse/[email protected]
| +-- @unhead/[email protected]
| | `-- [email protected] deduped
| `-- [email protected] deduped
+-- [email protected]
| `-- [email protected] deduped
`-- [email protected]
`-- @vue/[email protected]
`-- [email protected] deduped |
Just like @jiriferkl stated, installing everything at once, it magically worked just fine :/ |
I have got the problem with node 18.8 and npm 8.18. Stackblitz uses node 16 and npm 7. therefore a replication isn't possible using these online tools. |
This issue is still present using node v18.13.0 and npm v9.4.0 useQuery has the issue and still it's not solved. useAsyncQuery works fine. |
same here, nothing has fixed this. |
I'm having this same issue! forcing the |
I am seeing the same issue. We had Below are the relevant package versions I'm on:
Unfortunately, I wasn't able to get it working by simply reinstalling all of my packages at one time. I had to go ahead and install |
Today I was fiddling around a bit with the woot@woot-pc:~/dev/int/nuxt/apollo$ pnpm install
Scope: all 2 workspace projects
Lockfile is up to date, resolution step is skipped
Already up to date
. prepare$ nuxt-module-build --stub && nuxi prepare playground
│ ℹ Stubbing @nuxtjs/apollo
│ Nuxi 3.0.0
│ ✔ Types generated in playground/.nuxt
└─ Done in 2s
Done in 2.7s I could install it and I could even run the playground and could mutate the todo demo! So I thought maybe this works with a fresh nuxt install as well. woot@woot-pc:~/dev/int/nuxt/nptest$ pnpm install --shamefully-hoist
WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
Packages: +631
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
Content-addressable store is at: /home/woot/.local/share/pnpm/store/v3
Virtual store is at: node_modules/.pnpm
Progress: resolved 670, reused 415, downloaded 212, added 631, done
node_modules/.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, done in 46ms
node_modules/.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, done in 64ms
> @ postinstall /home/woot/dev/int/nuxt/nptest
> nuxt prepare
Nuxi 3.3.1 18:39:48
✔ Types generated in .nuxt 18:39:49
devDependencies:
+ nuxt 3.3.1
The integrity of 3179 files was checked. This might have caused installation to take longer.
Done in 12.2s
woot@woot-pc:~/dev/int/nuxt/nptest$ pnpm install @nuxtjs/apollo@next
WARN deprecated [email protected]: Please use @jridgewell/sourcemap-codec instead
WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
Packages: +30
++++++++++++++++++++++++++++++
Downloading registry.npmjs.org/typescript/4.9.5: 11.6 MB/11.6 MB, done
Progress: resolved 700, reused 646, downloaded 11, added 30, done
dependencies:
+ @nuxtjs/apollo 5.0.0-alpha.5
WARN Issues with peer dependencies found
.
├─┬ @nuxtjs/apollo 5.0.0-alpha.5
│ └─┬ @vue/apollo-composable 4.0.0-beta.1
│ ├── ✕ missing peer vue@"^2.6.0 || ^3.1.0"
│ ├─┬ ts-essentials 9.3.1
│ │ └── ✕ missing peer typescript@>=4.1.0
│ └─┬ vue-demi 0.13.11
│ └── ✕ missing peer vue@"^3.0.0-0 || ^2.6.0"
└─┬ nuxt 3.3.1
└─┬ @nuxt/vite-builder 3.3.1
└─┬ vite-plugin-checker 0.5.6
└── ✕ missing peer typescript@"*"
Peer dependencies that should be installed:
typescript@>=4.1.0 vue@">=3.0.0-0 <3.0.0 || >=3.1.0 <4.0.0 || >=2.6.0 <3.0.0"
Done in 6.6s The installation still complains about missing peers. That also should be fixed! I guess this has something to do with apollo-composable trying to keep giving support for vue 2 and the vue composition api. BUT! After that installation with pnpm @Diizzayy I hope this helps you finding the real issue here. |
Same issue on my end with a fresh install. |
This happens because when installed, npm i -D @vue/apollo-composable@latest --force |
@iamandrewluca It is a dependency that is needed by the Otherwise it should be mentioned in the documentation, that other packages have to be installed to make Also I think |
In case it helps anyone. To get I switched to Node v18, deleted Now I need to figure out why Apollo dev tools's tab is not working (it wasn't earlier either) and see if this plugin is persisting Apollo cache or not. It doesn't seem to be and thus means that we'll have to use another state management as opposed to Apollo which doesn't make sense. |
I got it working by adding peerDependencies "peerDependencies": { |
@keithmifsud this is really weird, because I am running on nde v 18 and honestly useQuery still doesn't work. Can you share your package.json and your nuxt.config.ts? |
try my package.json with node v16.19.1. I haven't tested with higher versions |
I had to stop using this module as it doesn't save use cached data 😞 |
With Nuxt3, it makes more sense to use API routes to fetch data using GQL. graph LR;
a[Nuxt Web]-->b[Nuxt API Routes];
b[Nuxt API Routes]-->c[Some GQL API];
In this way, your bundle will be even smaller, because you don't have to keep any of GQL Queries in your FE bundle |
@keithmifsud so you are saying that I cannot build an infinite scroll? @iamandrewluca do you mind elaborate more? could you provide an example? Maybe let's say you are querying a blog for posts. |
Hi @Dinuz ... I'm just saying that this plugin does not use Apollo cache. In its main composable, it overrides the cache options to |
I'm having the same issue as described above, getting an error that
But manually installing via
// node_modules/graphql/jsutils/instanceOf.mjs
var _globalThis$process;
var instanceOf = (
/* c8 ignore next 6 */
// FIXME: https://github.com/graphql/graphql-js/issues/2317
((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 ? void 0 : _globalThis$"development") === "production" ? function instanceOf2(value, constructor) {
return value in Please note that everything was working fine, until I touched the package.json to upgrade a seemingly unrelated package, TailwindCSS. Any other ideas, or suggestion for a real fix? |
I'm having this issue as well with |
Is this problem still unresolved? |
I manually installed all the packages and it worked for me. Not sure about the current conditions as I moved on from vue to other language 😂 |
With following versions - useMutation not working. few days back useAsyncQuery worked fine for mutations as well. As of now its not sending graphql call to server and we dont see any call in network tab. It became blocker for me. |
I'd definitely contribute and open a PR if I had the time, but unfortunately, that's not feasible right now. Opting to move away and install stable packages independently seems like the best choice to avoid potential headaches in the future. |
@Diizzayy I have the same issue. I followed the exact instructions from the website and I am getting the same error. |
I created an app with nuxtjs v3 rc-13 and
@nuxtjs/[email protected]
based on a pre defined project that I created with nuxt 3 rc-11.After I installed my dependencies and started
npm run dev
I got the error, thta@vue/apollo-composable
module is missing. That was because I forgot to remove import statements from my old project. After I removed them and cleared the nuxi cache I restarted the app and still got the error[plugin:vite:import-analysis] Failed to resolve import "@vue/apollo-composable" from "pages/[...pages].vue". Does the file exist?
I double checked that there is no import on my side. I guess that using
useQuery
with the nuxt configurationapollo: { autoImports: true }
doesn't work correctly. I Checked the dependencies of the@nuxtjs/[email protected]
module and saw, that it uses@vue/apollo-composable
internally, which is present in the modulesnode_module
folder.After I installed the package
@vue/apollo-composable
as my dependency, everything seems to work. But I think that's the wrong way. Could you please check this behaviour?The text was updated successfully, but these errors were encountered: