#Pnpm/Vite and monorepo package resolution

25 messages · Page 1 of 1 (latest)

rose dove
#

This could entirely be a node issue, but thought I'd post it here to see if anyone has possible fix. I have an existing repo with its own package.json/node_modules at the root. I'm then adding a new folder called frontends which will become a pnpm monorepo.

The interesting part is I've installed Remix into the apps folder, but when I try to start the dev server it throws the error for a package that is found outside the frontends directory and in the root project. Is there a way I can get pnpm/vite to only look at the workspace root?

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open '/Users/ericchernuka/workspace/xyz/frontends/apps/xyz-ssr/node_modules/@jobber/design/foundation.css'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/ericchernuka/workspace/xyz/frontends/apps/xyz-ssr/node_modules/@jobber/design/foundation.css'
}
young canyon
#

sorry i dont get this folder structure, can you expand a bit? or share a ss (via ibb.co/imgur, images are blocked)

#

what exactly are you trying to make into the monorepo? the frontends folder or the repo root

#

where is your pnpm-workspace.yaml

rose dove
#
xyz_project/
├─ frontends/
│  ├─ apps/
│  │  ├─ remix/
│  │  │  ├─ package.json
│  │  │  ├─ node_modules/
│  ├─ packages/
│  ├─ package.json
│  ├─ pnpm-workspaces.yml
│  ├─ node_modules/
├─ node_modules/
│  ├─ @jobber/
│  │  ├─ design/
│  │  │  ├─ foundations.css
├─ package.json

This is the rough structure. xyz_project is an existing rails project that has some node_modules usage. So I was looking to isolate the frontends project away from it for this POC I'm doing.

#

@young canyon Hopefully that helps paint a clearer picture.

#

I will also point out that my project does not include this library as a dependency anywhere in the frontends folder.

young canyon
#

are you not even importing it somehow?

#

wtf that is weird

rose dove
#

Correct. Its a bare-bones project

young canyon
#

uhh try nuking node_modules and reinstalling deps?

#

this is so weird 😂 is the remix app with the new unstable vite plugin?

#

if so, definitely try nuking node modules if you've moved it around

rose dove
#

I'll try the same thing without the vite plugin. Just to confirm

#

Interesting. It was the vite plugin version. Installing just a basic remix it works fine.

young canyon
#

check which node_modules has a .vite folder inside

#

some prebundled libs might be using old paths or something

#

(wild guess)

rose dove
#

the remix app is the only one that has the .vite folder in node_modules.

#

Though, removing all the plugins, it still complained so it seemed like Vite was reaching outside 🤔

young canyon
#

hmm that's very weird

#

why would it even try to import it lol

rose dove
#

Ok I figured it all out I believe. Postcss was being initialized and couldn't find a postcss.config.js so it went up a directory to find it. Which I think then set the root for something in vite/remix and everything went downhill. Adding a basic one for tailwind prevents it from crawling.

young canyon
#

Ahhh hahaha damn

rose dove
#

Thanks for the assitance.