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

Vite error in dev ssr mode: Failed to resolve entry for package "vitedge". #71

Closed
wvffle opened this issue Dec 21, 2021 · 3 comments
Closed

Comments

@wvffle
Copy link

wvffle commented Dec 21, 2021

To create a basic app with vitedge, I started with the guide on the docs. I did pretty much everything from the start a couple of times but there were always the same results.

But when I tried to run yarn dev, the following error occured:

Failed to resolve entry for package "vitedge". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "vitedge". The package may have incorrect main/module/exports specified in its package.json.

    at packageEntryFailure (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30629:11)
    at resolvePackageEntry (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30625:9)
    at tryNodeResolve (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30448:20)
    at viteResolve (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67795:26)
    at nodeImport (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67823:15)
    at ssrImport (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67731:20)
    at eval (/home/waff/workspace/wvffle.net/src/main.js:3:37)
    at instantiateModule (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67776:15

When I try to reload the page myself, the error changes:

resolve is not a function

    at Object.getRenderContext (file:///home/waff/workspace/wvffle.net/node_modules/vitedge/dev/middleware.js:302:22)
    at handleSsrRequest (/home/waff/workspace/wvffle.net/node_modules/vite-ssr/dev/server.js:97:32

Here are my dependencies:

{
  "@vue/server-renderer": "3",
  "@vueuse/head": "^0.7.4",
  "vitedge": "^0.17.3",
  "vue": "3",
  "vue-router": "4"
}
{
  "@vitejs/plugin-vue": "^2.0.0",
  "vite": "^2.7.5"
}

I'm using node 17:

λ ~/workspace/wvffle.net/ node -v
v17.3.0
@wvffle
Copy link
Author

wvffle commented Dec 21, 2021

It turned out that I had some other error (I was playing a bit with everything when that happened just after configuring the project and I introduced a missing component) and vitedge was displaying that instead of the original error in the web ui.

@wvffle wvffle closed this as completed Dec 21, 2021
@wvffle
Copy link
Author

wvffle commented Dec 21, 2021

Okay, the issue still exists on vite@2.7.x though it doesn't seem to be an issue on vite@2.6.x

Here's the full error from the console:

12:01:38 AM [vite] Error when evaluating SSR module /home/waff/workspace/wvffle.net/src/main.js:
Error: Failed to resolve entry for package "vitedge". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "vitedge". The package may have incorrect main/module/exports specified in its package.json.
    at packageEntryFailure (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30629:11)
    at resolvePackageEntry (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30625:9)
    at tryNodeResolve (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30448:20)
    at viteResolve (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67795:26)
    at nodeImport (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67823:15)
    at ssrImport (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67731:20)
    at eval (/home/waff/workspace/wvffle.net/src/main.js:3:37)
    at instantiateModule (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67776:15)
12:01:39 AM [vite] Internal server error: Failed to resolve entry for package "vitedge". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "vitedge". The package may have incorrect main/module/exports specified in its package.json.
      at packageEntryFailure (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30629:11)
      at resolvePackageEntry (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30625:9)
      at tryNodeResolve (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:30448:20)
      at viteResolve (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67795:26)
      at nodeImport (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67823:15)
      at ssrImport (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67731:20)
      at eval (/home/waff/workspace/wvffle.net/src/main.js:3:37)
      at instantiateModule (/home/waff/workspace/wvffle.net/node_modules/vite/dist/node/chunks/dep-bc5f477e.js:67776:15)

@wvffle wvffle reopened this Dec 21, 2021
@frandiox
Copy link
Owner

frandiox commented Dec 26, 2021

Looks like Vite 2.7.x changed the way SSR modules are loaded for "type": "module" projects and it does not respect Vite aliases anymore :(
This is something that needs to be fixed in Vite itself I think.

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

2 participants