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] Failed to resolve import "#ansi-styles" #92

Closed
paulexconde opened this issue Sep 23, 2022 · 10 comments
Closed

[BUG] Failed to resolve import "#ansi-styles" #92

paulexconde opened this issue Sep 23, 2022 · 10 comments

Comments

@paulexconde
Copy link

Bug report

Report for: lucia-sveltekit

Node doesn't recognize something in import statement

Current behavior

Failed to resolve import "#ansi-styles" from "node_modules/.pnpm/chalk@5.0.1/node_modules/chalk/source/index.js?v=e4b116c2". Does the file exist?

Possible cause

It looks like the depedency used chalk@5.0.1 is using ESM, check this for more info

Additional info

Version

chalk@5.0.1

Additional notes

My suggestion is to used version 4 of chalk dependency

@pilcrowOnPaper
Copy link
Member

That’s weird, Lucia doesn’t use chalk. I don’t remember if I published it but one of the iteration used chalk, and I had the same error. Are you using the latest version?

@paulexconde
Copy link
Author

That’s weird, Lucia doesn’t use chalk. I don’t remember if I published it but one of the iteration used chalk, and I had the same error. Are you using the latest version?

Yeah, it occurs when I update my dependencies including sveltekit

@pilcrowOnPaper
Copy link
Member

Yeah, not sure on this one. I tried to recreate it but I can't get the same error to appear.

@vdelacerda
Copy link

vdelacerda commented Sep 27, 2022 via email

@paulexconde
Copy link
Author

Yeah, not sure on this one. I tried to recreate it but I can't get the same error to appear.

Somehow the issue did not occur when i try lucia again to my app, Weird 😕

@cotyhamilton
Copy link

cotyhamilton commented Sep 30, 2022

I'm experiencing this, it's a bit of a strange issue. When installing the prisma adapter, it's like it's installing an old version of lucia that has the chalk dependency

coty packages/budget-api 
➜ yarn add @lucia-sveltekit/adapter-prisma 
yarn add v1.22.19
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 24 new dependencies.
info Direct dependencies
└─ @lucia-sveltekit/adapter-prisma@0.3.3
info All dependencies
├─ @lucia-sveltekit/adapter-prisma@0.3.3
├─ @sveltejs/package@1.0.0-next.3
├─ anymatch@3.1.2
├─ binary-extensions@2.2.0
├─ braces@3.0.2
├─ chalk@5.0.1
├─ chokidar@3.5.3
├─ dedent-js@1.0.1
├─ fill-range@7.0.1
├─ glob-parent@5.1.2
├─ is-binary-path@2.1.0
├─ is-extglob@2.1.1
├─ is-glob@4.0.3
├─ is-number@7.0.0
├─ kleur@4.1.5
├─ lower-case@2.0.2
├─ mri@1.2.0
├─ no-case@3.0.4
├─ normalize-path@3.0.0
├─ pascal-case@3.1.2
├─ readdirp@3.6.0
├─ sade@1.8.1
├─ svelte2tsx@0.5.19
└─ to-regex-range@5.0.1
Done in 2.90s.

I get this entry in yarn.lock after installing the adapter

lucia-sveltekit@0.8.2:
  version "0.8.2"
  resolved "https://registry.yarnpkg.com/lucia-sveltekit/-/lucia-sveltekit-0.8.2.tgz#ef2c7361583fc206a6b8481e2ad344957c3bfe01"
  integrity sha512-YhjeKLL8L73zoH7Y9PC+H8RHPAv0tlGyiicJSseCMvYyFCHIIytIrvNPngR2uDz+OJyvBXaaTzrQ605y3Y8BBQ==
  dependencies:
    "@sveltejs/package" "1.0.0-next.3"
    chalk "^5.0.1"
    cookie "^0.5.0"
    jsonwebtoken "^8.5.1"
    nanoid "^4.0.0"

And the error from build (I've created a wrapper library around lucia to create a generic api provider in my sveltekit project, so this is thrown when building the sveltkit project that includes my library that includes your library)

[vite]: Rollup failed to resolve import "#ansi-styles" from "node_modules/@avamoney/budget-api/node_modules/chalk/source/index.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
error during build:

@pilcrowOnPaper
Copy link
Member

@cotyhamilton

I’ll try to rebuild and republish the adapters.

@cotyhamilton
Copy link

Downgrading @lucia-sveltekit/adapter-prisma to 0.3.1 gets me past this, fyi

@garlandcrow
Copy link

I've seen this pop up here and there and I've noticed that wiping out node_modules and recreating always fixed for me but sometimes I have had to do that a few times ?? It might be something w/ how newer versions of vite "optimize" things the first time they are seen but thats just a wild guess.

@pilcrowOnPaper
Copy link
Member

I've removed the cli-color dependency from the lucia-auth so this shouldn't be an issue

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

5 participants