admin管理员组

文章数量:1276836

I use vite on react, and when i use yarn to "live server" my project two new files are created, .pnp.loader.mjs and .pnp.cjs. What is the purpose of this files? I never see those files, always use npm or yarn and is the first time that they appear.

I use vite on react, and when i use yarn to "live server" my project two new files are created, .pnp.loader.mjs and .pnp.cjs. What is the purpose of this files? I never see those files, always use npm or yarn and is the first time that they appear.

Share Improve this question edited Jul 19, 2023 at 17:41 yivi 47.3k18 gold badges130 silver badges153 bronze badges asked Dec 30, 2022 at 4:12 Esteban SaboEsteban Sabo 2011 gold badge2 silver badges7 bronze badges 3
  • Any update on this one? – abiratsis Commented Jan 8, 2023 at 12:54
  • yarnpkg.com/features/pnp – nsevens Commented Jan 30, 2023 at 7:58
  • 1 The doc doesn't mention the .pnp.loader.mjs. – Moritz Kampfinger Commented Mar 24, 2023 at 10:57
Add a comment  | 

3 Answers 3

Reset to default 13

The .pnp.cjs is part of the Yarn Plug'n'Play process, which makes our install and runtime much faster. It makes the node_modules obsolete.

Yarn also creates an experimental ESM loader which is called .pnp.loader.mjs.

If you do not want the .pnp.cjs to be created, create a .yarnrc.yml file in the root directory, add : nodeLinker: node-modules

npx create-next-app@latest
npx next dev

The issue is from Yarn @Jan Willems says

本文标签: javascriptWhy yarn creates a pnploadermjs and pnpcjs filesStack Overflow