Esteban Sabo
Esteban Sabo

Reputation: 201

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

Upvotes: 20

Views: 13764

Answers (3)

Tiavina MIchael
Tiavina MIchael

Reputation: 381

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

Upvotes: 7

Yohann Atticot
Yohann Atticot

Reputation: 21

npx create-next-app@latest
npx next dev

The issue is from Yarn @Jan Willems says

Upvotes: 0

Jan Willems
Jan Willems

Reputation: 131

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.

Upvotes: 13

Related Questions