Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why yarn creates a .pnp.loader.mjs and .pnp.cjs files

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.

files

like image 630
Esteban Sabo Avatar asked Nov 29 '25 01:11

Esteban Sabo


2 Answers

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.

like image 105
Jan Willems Avatar answered Dec 01 '25 15:12

Jan Willems


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

like image 39
Tiavina MIchael Avatar answered Dec 01 '25 13:12

Tiavina MIchael