farm-fe / farm

Extremely fast Vite-compatible web build tool written in Rust
https://farmfe.org
MIT License
4.42k stars 150 forks source link

[Bug Report]: farm does not work with yarn berry PnP #1421

Open decademoon opened 2 weeks ago

decademoon commented 2 weeks ago

Steps to reproduce

Create Vue 3 project:

yarn create farm myapp --template vue3
cd myapp
yarn
yarn add --dev vite # See issue 1420
yarn start # Works

Upgrade to modern yarn version:

yarn set version stable
yarn
yarn start # Works

Use PnP node linker: modify the .yarnrc.yml file to change nodeLinker from node-modules to pnp. Or just delete the file.

yarn
yarn start # Fails

Error:

[ Farm ] Using config file at /private/tmp/myapp/farm.config.ts
[ Farm ] Failed to start the server:
 Error: Failed to load farm config file: Can not resolve `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` from /private/tmp/myapp.
Original error: None.

Potential Causes:
1.The file that `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` points to does not exist.
2.Install it first if `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` is an dependency from node_modules, if you are using pnpm refer to [https://pnpm.io/faq#pnpm-does-not-work-with-your-project-here] for solutions.
3. If `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` is a alias, make sure your alias config is correct.

 Error: ["Can not resolve `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` from /private/tmp/myapp.\nOriginal error: None.\n\nPotential Causes:\n1.The file that `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` points to does not exist.\n2.Install it first if `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` is an dependency from node_modules, if you are using pnpm refer to [https://pnpm.io/faq#pnpm-does-not-work-with-your-project-here] for solutions.\n3. If `/Users/foo/.yarn/berry/cache/@farmfe-runtime-npm-0.11.1-89f6526c45-10c0.zip/node_modules/@farmfe/runtime/src/index.ts.farm-runtime` is a alias, make sure your alias config is correct.\n"]

Reproduce link

No response

What is actually happening?

yarn start fails when the project is using yarn berry with PnP enabled.

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 766.84 MB / 32.00 GB
    Shell: 3.7.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 22.3.0 - /opt/homebrew/bin/node
    Yarn: 4.3.1 - /opt/homebrew/bin/yarn
    npm: 10.8.1 - /opt/homebrew/bin/npm
    bun: 1.1.15 - /opt/homebrew/bin/bun
nmoinvaz commented 6 days ago

Also have the same problem. 🥹