activist icon indicating copy to clipboard operation
activist copied to clipboard

Investigate and update Yarn install process (Yarn PnP and Zero-installs)

Open andrewtavis opened this issue 9 months ago • 12 comments
trafficstars

Terms

Description

In #1107 we updated to Yarn v4.x. This issue is to investigate and update the current Yarn process where we'd make use of the modern features of Yarn.

Specifically we would:

  • Remove node_modules
  • Switch over to a version controlled .yarn directory such that we don't need to install
  • Update .gitignore to ignore the needed files (docs)

The following documentation would be helpful for this:

[!NOTE] We need to make sure that this will also work for our Netlify builds.

Contribution

Happy to discuss this and support someone who has interest in working on it! 😊

andrewtavis avatar Jan 28 '25 20:01 andrewtavis

Hello @andrewtavis I am looking into this, I will update to you soon. In the mean time can you please assign this issue to me. 😊

Abhi-Bohora avatar Feb 05 '25 13:02 Abhi-Bohora

Hey @Abhi-Bohora 👋 Another person wanted to work on this, but I'll check with them and see if there's something else that's of interest :) For now it's ok to continue, and thanks for your enthusiasm in working with us 😊

andrewtavis avatar Feb 05 '25 18:02 andrewtavis

Quick note from a call, @Abhi-Bohora: The other contributor is happy if you'd like to take this on :) Please let us know if there's anything we can do to support! 😊

andrewtavis avatar Feb 05 '25 19:02 andrewtavis

Hello @andrewtavis I have tried to migrate this but there seems to be some problems with the dependencies especially with @nuxt/kit while using yarn plug and play. i have tracked the issue and got here https://github.com/nuxt/nuxt/issues/26750 they are suggesting nodeLinker: node_modules but i think we don't want that when using pnp the goal was to remove node_modules and load the dependencies from cache. if you have any suggestion or anyone might suggest something regarding this issue that might be great help. i tried to use this setting in .yarnrc.yml

# .yarnrc.yml
nodeLinker: pnp
enableGlobalCache: false
enableScripts: true
pnpMode: loose
enableTransparentWorkspaces: true

packageExtensions:
  "nuxt@*":
    dependencies:
      "@nuxt/kit": "*"
      "@nuxt/schema": "*"
      "pathe": "*"
      "unimport": "*"
      "nitropack": "*"
  "@nuxt/kit@*":
    dependencies:
      "@nuxt/schema": "*"
      "pathe": "*"
      "unimport": "*"
      "nitropack": "*"
  "@nuxt/cli@*":
    dependencies:
      "@nuxt/kit": "*"
      "@nuxt/schema": "*"
  "@nuxt/schema@*":
    dependencies:
      "@nuxt/kit": "*"
      "pathe": "*"
  "nitropack@*":
    dependencies:
      "pathe": "*"

i got error while running yarn install and this is the error contents of the log file

# This file contains the result of Yarn building a package (activist@workspace:.)
# Script name: postinstall


[41m[30m ERROR [39m[49m Your application tried to access @nuxt/kit, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @nuxt/kit (via "@nuxt\kit")
Required by: C:\Users\abhis\Desktop\os\activist\frontend\

Require stack:
- C:\Users\abhis\Desktop\os\activist\frontend\_index.js

  
  Required package: @nuxt/kit ([36mvia "@nuxt\kit"[39m)
  Required by: 
  
  Require stack:
  - _index.js
  [90mat [39mrequire$$0.Module._resolveFilename ([36m.pnp.cjs:32198:13[39m)
  [90mat [39mFunction.resolve ([36mnode:internal/modules/helpers:190:19[39m)
  [90mat [39mjitiResolve ([36m.yarn\cache\jiti-npm-2.4.2-d980cbb540-4ceac133a0.zip\node_modules\jiti\dist\jiti.cjs:1:187220[39m)
  [90mat [39mjitiRequire ([36m.yarn\cache\jiti-npm-2.4.2-d980cbb540-4ceac133a0.zip\node_modules\jiti\dist\jiti.cjs:1:189288[39m)
  [90mat [39mFunction.import ([36m.yarn\cache\jiti-npm-2.4.2-d980cbb540-4ceac133a0.zip\node_modules\jiti\dist\jiti.cjs:1:199778[39m)
  [90mat [39mloadKit ([36m/C:/Users/abhis/Desktop/os/activist/frontend/.yarn/cache/@nuxt-cli-npm-3.20.0-b9d9d55aec-043dc306f5.zip/node_modules/@nuxt/cli/dist/shared/cli.DlcAx0De.mjs:8:32[39m)
  [90mat [39masync Object.run ([36m/C:/Users/abhis/Desktop/os/activist/frontend/.yarn/cache/@nuxt-cli-npm-3.20.0-b9d9d55aec-043dc306f5.zip/node_modules/@nuxt/cli/dist/chunks/prepare.mjs:29:49[39m)
  [90mat [39masync runCommand ([36m/C:/Users/abhis/Desktop/os/activist/frontend/.yarn/cache/citty-npm-0.1.6-60b76c16d8-d26ad82a9a.zip/node_modules/citty/dist/index.mjs:316:16[39m)
  [90mat [39masync runCommand ([36m/C:/Users/abhis/Desktop/os/activist/frontend/.yarn/cache/citty-npm-0.1.6-60b76c16d8-d26ad82a9a.zip/node_modules/citty/dist/index.mjs:307:11[39m)
  [90mat [39masync runMain ([36m/C:/Users/abhis/Desktop/os/activist/frontend/.yarn/cache/citty-npm-0.1.6-60b76c16d8-d26ad82a9a.zip/node_modules/citty/dist/index.mjs:445:7[39m) 



[41m[30m ERROR [39m[49m Your application tried to access @nuxt/kit, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: @nuxt/kit (via "@nuxt\kit")
Required by: C:\Users\abhis\Desktop\os\activist\frontend\

Require stack:
- C:\Users\abhis\Desktop\os\activist\frontend\_index.js

Abhi-Bohora avatar Feb 21 '25 05:02 Abhi-Bohora

We can definitely take a look at this, @Abhi-Bohora! Would you have interest in attending the dev sync tomorrow and talking about it there? Information on it is in the development channel on Matrix :)

andrewtavis avatar Feb 21 '25 08:02 andrewtavis

yes i am interested. can you please provide me some more information on what we generally talk about in dev sync ? I can see the call link in element app in activist development room, i can just join in tomorrow right ? 😅 Thanks

Abhi-Bohora avatar Feb 21 '25 12:02 Abhi-Bohora

We do quick introductions as new people join, and then from there we talk about the various issues we're working on and the community supports with ideas and sharing what context they have when we've worked in similar parts of the codebase :) Would be great to have you there! 😊

andrewtavis avatar Feb 21 '25 15:02 andrewtavis

sounds great I will be there...❤️

Abhi-Bohora avatar Feb 21 '25 17:02 Abhi-Bohora

Were you able to make any progress with the base Nuxt install, @Abhi-Bohora? Just checking in here :)

andrewtavis avatar Mar 01 '25 20:03 andrewtavis

Hello @andrewtavis I forget to update here 😅. Yeah i have made fresh Nuxt project using yarn and followed the migration steps from here but it is giving me the same @nuxt/kit error which i had migrating our project. switching from nodeLinker: node_modules to nodeLinker: pnp gives me this error. when switching to pnp it feels like somehow it cannot find the dependencies.

I find this discussion but i think they are having problem with supporting pnp or something. didn't find something useful for us

Image

Abhi-Bohora avatar Mar 02 '25 14:03 Abhi-Bohora

Sounds good, @Abhi-Bohora! Thanks for the investigations :)

andrewtavis avatar Mar 02 '25 17:03 andrewtavis

I'll block this for now and un-assign you. We can look at this again in a few months and maybe there'll be a solution then 😊

andrewtavis avatar Mar 02 '25 17:03 andrewtavis