Using Yarn 2 or later, the default installation method creates a .pnp.js file (Plug'n'Play) instead of a node_modules directory.
How do I use this file to run my Node application?
To run a Node application with Yarn's Plug'n'Play you must preload the .pnp.js file using the --require flag.
node --require ./.pnp.js foo.js
Note: Make sure that the --require path starts with ./ or ../.
To start an ESM application, you also need to use the --loader flag (both flags are needed).
node --require ./.pnp.cjs --loader ./.pnp.loader.mjs foo.mjs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With