Using Yarn 2, 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