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

Error [ERR_UNSUPPORTED_DIR_IMPORT] #119

Open
happysalada opened this issue Feb 28, 2022 · 3 comments
Open

Error [ERR_UNSUPPORTED_DIR_IMPORT] #119

happysalada opened this issue Feb 28, 2022 · 3 comments

Comments

@happysalada
Copy link

Hi, thank you for the project!

Upon adding this to an almost brand-new svelte kit project with adapter static, I get the following error

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/Users/raphael/dev/nyt/node_modules/.pnpm/svelte-apo
[email protected]_0797cffbf2a19052134926e8d6fad18a/node_modules/@apollo/client/core' is not supported resolving ES
 modules imported from /Users/raphael/dev/nyt/node_modules/.pnpm/[email protected]_0797cffbf2a1905213492
6e8d6fad18a/node_modules/svelte-apollo/dist/svelte-apollo.js
Did you mean to import @[email protected][email protected]/node_modules/@apollo/client/core/core.cjs?
    at new NodeError (internal/errors.js:322:7)
    at finalizeResolution (internal/modules/esm/resolve.js:314:17)
    at moduleResolve (internal/modules/esm/resolve.js:776:10)
    at Loader.defaultResolve [as _resolve] (internal/modules/esm/resolve.js:887:11)
    at Loader.resolve (internal/modules/esm/loader.js:89:40)
    at Loader.getModuleJob (internal/modules/esm/loader.js:242:28)
    at ModuleWrap.<anonymous> (internal/modules/esm/module_job.js:76:40)
    at link (internal/modules/esm/module_job.js:75:36)

I've tried to check your example svelte-kit to see if there was anything different in the config, but couldn't find anything.
I've almost taken verbatim the code you had in your example.
this is the relevant part from my index.svelte

	import { ApolloClient, InMemoryCache, gql } from "@apollo/client/core";
	import { setClient, query, mutation } from "svelte-apollo";	
  import { AGENTS } from '$lib/queries'
	const client = new ApolloClient({
		uri: "https://yq4l7sc1.directus.app/gql",
		cache: new InMemoryCache()
	});
	setClient(client);
@cluplau
Copy link

cluplau commented Mar 27, 2022

I have experienced the same thing. @timhall any insight on this?

@j2l
Copy link

j2l commented Apr 5, 2022

I took the zip of this great project, extracted the sveltekit example and run into the same issue.

Following proposed fixed, I tried:

import pkg from '@apollo/client/core/core.cjs';
const { InMemoryCache, gql } = pkg;
import { ApolloClient } from '@apollo/client/core/ApolloClient';

without luck, now with error in the apollo module itself .../node_modules/@apollo/client/utilities/globals/fix-graphql.js:1 import { remove } from "ts-invariant/process/index.js";

@lorensr
Copy link

lorensr commented May 22, 2022

Adding this to my svelte.config.js worked:

      optimizeDeps: {
        exclude: ['@apollo/client', 'svelte-apollo'],
      },
      ssr: {
        noExternal: ['@apollo/client', 'svelte-apollo'],
      },

to kit.vite

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants