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: cannot resolve asset path in turborepo monorepo #7927

Closed
1 task done
lithdew opened this issue Nov 7, 2023 · 6 comments
Closed
1 task done

Vite: cannot resolve asset path in turborepo monorepo #7927

lithdew opened this issue Nov 7, 2023 · 6 comments

Comments

@lithdew
Copy link

lithdew commented Nov 7, 2023

What version of Remix are you using?

2.2.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

  1. git clone https://github.com/lithdew/remix-vite-monorepo.git
  2. npm install
  3. npm run dev

Expected Behavior

It works.

Actual Behavior

% npm run dev

> dev
> vite dev


  VITE v4.5.0  ready in 597 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  ⚠️  Remix support for Vite is unstable
     and not recommended for production

9:53:10 PM [vite] Internal server error: Cannot resolve asset path "/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/config/defaults/entry.server.node.tsx" outside of root directory "/Users/dew/remix-vite-monorepo/remix-vite-monorepo/apps/web".
      at resolveFileUrl (/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/vite/plugin.js:74:11)
      at getServerEntry (/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/vite/plugin.js:197:51)
      at async Context.load (/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/vite/plugin.js:434:20)
      at async Object.load (file:///Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44323:32)
      at async loadAndTransform (file:///Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:54954:24)
      at async instantiateModule (file:///Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55951:10)
@izznatsir
Copy link
Contributor

Could you make a reproduction repo? I'm using react-aria-components with remix vite plugin without a problem.

@lithdew
Copy link
Author

lithdew commented Nov 7, 2023

Could you make a reproduction repo? I'm using react-aria-components with remix vite plugin without a problem.

Oh interesting, would you be able to provide the configs you have for your project?

I'll be able to make the reproduction repo in a bit.

@lithdew
Copy link
Author

lithdew commented Nov 7, 2023

While making the reproduction repo, I think I found the source of the bug. I explicitly created the Remix Vite repo inside of a Turborepo mono repository. I believe what Vite was complaining about was that the "react" dependency was in the node_modules of the monorepo folder rather than the node_modules of the Remix Vite project folder instead.

Copying the Remix Vite project folder outside of the Turborepo monorepo and re-installing dependencies causes the code to work again.

@lithdew
Copy link
Author

lithdew commented Nov 8, 2023

Created a reproduction here: https://github.com/lithdew/remix-vite-monorepo

% npm run dev

> dev
> vite dev


  VITE v4.5.0  ready in 597 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: use --host to expose
  ➜  press h to show help

  ⚠️  Remix support for Vite is unstable
     and not recommended for production

9:53:10 PM [vite] Internal server error: Cannot resolve asset path "/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/config/defaults/entry.server.node.tsx" outside of root directory "/Users/dew/remix-vite-monorepo/remix-vite-monorepo/apps/web".
      at resolveFileUrl (/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/vite/plugin.js:74:11)
      at getServerEntry (/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/vite/plugin.js:197:51)
      at async Context.load (/Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/@remix-run/dev/dist/vite/plugin.js:434:20)
      at async Object.load (file:///Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:44323:32)
      at async loadAndTransform (file:///Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:54954:24)
      at async instantiateModule (file:///Users/dew/remix-vite-monorepo/remix-vite-monorepo/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:55951:10)

@lithdew lithdew changed the title Vite: unable to import react-aria-components Vite: cannot resolve asset path in turborepo monorepo Nov 8, 2023
@hi-ogawa
Copy link
Contributor

hi-ogawa commented Nov 9, 2023

Thanks for the reproduction.
I think this is a duplicate of #7722. Pnpm workspace also had the same issue but it will be fixed in #7913
Until the fix is released, you can workaround it by using remix reveal to copy the default entry files to to your app folder (see https://remix.run/docs/en/main/file-conventions/entry.client)

@lithdew
Copy link
Author

lithdew commented Nov 9, 2023

Thanks for the reproduction. I think this is a duplicate of #7722. Pnpm workspace also had the same issue but it will be fixed in #7913 Until the fix is released, you can workaround it by using remix reveal to copy the default entry files to to your app folder (see https://remix.run/docs/en/main/file-conventions/entry.client)

This worked, many thanks.

@lithdew lithdew closed this as completed Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants