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

Compatibility with Nuxt 4 #20

Closed
Gobler opened this issue Jul 17, 2024 · 12 comments
Closed

Compatibility with Nuxt 4 #20

Gobler opened this issue Jul 17, 2024 · 12 comments
Assignees

Comments

@Gobler
Copy link

Gobler commented Jul 17, 2024

Nuxt 4(or running in compatibility mode) has a new application structure - unfortunately, at the moment the module does not support the new structure and it is not possible to run the application with the module active.

@Gobler
Copy link
Author

Gobler commented Jul 17, 2024

I see that the above problem is probably related to #15 - I using pnpm and in addition it is working with monorepo and nuxt layers...

will test it a bit more but I also get an "ERROR ✘ Failed to install Prisma Client." error and everything crashes

@ankur-arch
Copy link
Contributor

Hey @Gobler there's a PR to fix #15 , I'm working on merging it in and then we can see if this gets resolved.

@ankur-arch ankur-arch self-assigned this Jul 31, 2024
@ankur-arch
Copy link
Contributor

Hey @Gobler the PR has been merged, can see if it the crash is resolved?

Plus could you provide a minimal reproduction for your issue?

@husayt
Copy link

husayt commented Aug 3, 2024

I am getting this error while using prisma with pnpm workspaces.
The project is a nuxt layer extending another nuxt app from the same workspace with prisma functionality

image

@Dobefu
Copy link
Contributor

Dobefu commented Aug 4, 2024

Hi @husayt!

Not sure if this helps, but I know that npm gets used over other package managers if there are multiple lockfiles. This might be what is happening here, but I'm missing some information. If you happen to have both a package-lock.json and a pnpm-lock.yaml, does the issue still occur after deleting the package-lock.json?

@husayt
Copy link

husayt commented Aug 4, 2024 via email

@Dobefu
Copy link
Contributor

Dobefu commented Aug 4, 2024

My goodness, that's a quick response 🙂.
The error would suggest that the code is calling the npm command somewhere. It's nighttime for me now, so I can look tomorrow. But do you happen to have a minimal reproduction?

@husayt
Copy link

husayt commented Aug 4, 2024

I will try to come up with repro, but in case if someone came across this will be good to hear from them

@Dobefu
Copy link
Contributor

Dobefu commented Aug 5, 2024

Ah, I think I see what is happening now. Here's the relevant code for the issue:

function detectPackageManager(): PackageManager {
  // Check for package-lock.json
  if (existsSync("package-lock.json")) {
    return "npm";
  }
 
  // Check for yarn.lock
  if (existsSync("yarn.lock")) {
    return "yarn";
  }
 
  // Check for pnpm-lock.yaml
  if (existsSync("pnpm-lock.yaml")) {
    return "pnpm";
  }
 
  // bun.lockb
  if (existsSync("bun.lockb")) {
    return "bun";
  }
 
  // Default to npm if none of the above are found
  return "npm";
}

I see two things happening here:

  1. The function only looks in the current directory
  2. The fallback does not print a warning, which might be desirable

I will check if I can create a minimal reproduction, and link a repo containing said reproduction.

@Dobefu
Copy link
Contributor

Dobefu commented Aug 5, 2024

I've managed to reproduce the issue in Nuxt 3. I'll create a new issue, since it doesn't appear to be a Nuxt 4 issue

@ankur-arch
Copy link
Contributor

Thanks for jumping in @Dobefu , closing this in favour of #29.

@andreakru
Copy link

andreakru commented Dec 13, 2024

I am testing the module with Nuxt 4 but I got an error. Is there any specific branch I have to use?

@ankur-arch

Error when running pnpm dev after installation

✘ [ERROR] Could not resolve ".prisma/client/index-browser"

node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/index-browser.js:1:23:
  1 │ const prisma = require('.prisma/client/index-browser')
    ╵                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

You can mark the path ".prisma/client/index-browser" as external to exclude it from the bundle,
which will remove this error and leave the unresolved path in the bundle. You can also surround
this "require" call with a try/catch block to handle this failure at run-time instead of
bundle-time.

ERROR [unhandledRejection] Build failed with 1 error: 12:18:17 PM
node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/index-browser.js:1:23: ERROR: Could not resolve ".prisma/client/index-browser"

node_modules/.pnpm/@prisma+client@5.22.0_prisma@6.0.1/node_modules/@prisma/client/index-browser.js:1:23: ERROR: Could not resolve ".prisma/client/index-browser"
at failureErrorWithLog (node_modules/.pnpm/esbuild@0.24.0/node_modules/esbuild/lib/main.js:1476:15)
at node_modules/.pnpm/esbuild@0.24.0/node_modules/esbuild/lib/main.js:945:25
at node_modules/.pnpm/esbuild@0.24.0/node_modules/esbuild/lib/main.js:1354:9
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

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