framework icon indicating copy to clipboard operation
framework copied to clipboard

H3Error: Cannot find package graphql

Open alex-demchenko opened this issue 3 years ago • 6 comments

Environment

OS: Linux Node: v17.8.0 Nuxt: 3.0.0-rc.6 Package manager: npm Bilder: vite

Reproduction

Project for reproduction: nuxt-h3-error-cant-find-package-graphql

  1. Run: npm run build
  2. Run: npm run start
  3. Will open main page which automatially send graphql request to backend and receive 500 internal server error, which can be see in console
  4. Check terminal log with H3 Error (see Logs section)

Actual result: text on the main page - [] Expected result: text on the main page - ['test1', 'test2']

Describe the bug

Hi! I use graphql library (https://github.com/graphql/graphql-js) in my project, and when I build and run a project, I receive H3Error: Cannot find package, more detail message in the Logs secton.

Additional context

No response

Logs

Listening on http://0.0.0.0:3000/
 [h3] [unhandled] H3Error: Cannot find package '/var/mywebsite/.output/server/node_modules/graphql/' imported from /var/mywebsite/.output/server/chunks/graphqlnuxt.mjs
     at createError (file:///var/mywebsite/.output/server/node_modules/h3/dist/index.mjs:196:15)
     at Server.nodeHandler (file:///var/mywebsite/.output/server/node_modules/h3/dist/index.mjs:386:21) {
   statusCode: 500,
   fatal: false,
   unhandled: true,
   statusMessage: 'Internal Server Error'
 }
 [nuxt] [request error] Cannot find package '/var/mywebsite/.output/server/node_modules/graphql/' imported from /var/mywebsite/.output/server/chunks/graphqlnuxt.mjs
   at createError (./.output/server/node_modules/h3/dist/index.mjs:196:15)
   at Server.nodeHandler (./.output/server/node_modules/h3/dist/index.mjs:386:21)

alex-demchenko avatar Aug 03 '22 15:08 alex-demchenko

Would you provide a reproduction? 🙏

danielroe avatar Aug 03 '22 15:08 danielroe

Yeah, please let me some time to prepare a repository

alex-demchenko avatar Aug 03 '22 18:08 alex-demchenko

I updated the description of issue and added link to a reproduction project

alex-demchenko avatar Aug 03 '22 19:08 alex-demchenko

@DreadIsBack i installed it locally and it works. I cant reproduce the bug. Have your tried a fresh install ? rm -rf node_modules package-lock.json .output .nuxt Tested with node v17.8

CodeDredd avatar Aug 04 '22 13:08 CodeDredd

@CodeDredd This is pretty strange, I tried to do it three times, and each time I receive the error.

alex-demchenko avatar Aug 04 '22 19:08 alex-demchenko

I'm facing a similar issue https://github.com/nuxt/framework/issues/6144

In my case the cause is, I'm trying to import from a typescript library module in my plugins/api.plugin.ts file.

Just leaving it here as it might be related. Still could not solve it till now

mklueh avatar Aug 05 '22 06:08 mklueh

Fixed by updating to nuxt-rc.8 and reinstall all packages. I will close this issue. Thanks all.

alex-demchenko avatar Aug 17 '22 12:08 alex-demchenko