{"id":20150,"library":"jest-pnp-resolver","title":"jest-pnp-resolver","description":"A plug'n'play (PnP) resolver for Jest that enables resolution of dependencies in Yarn PnP environments. Current stable version is 1.2.3, with infrequent releases. Key differentiators: it is the official resolver for Yarn PnP with Jest, and as of Jest 24.4.0+, it is integrated by default, but manual setup may still be needed for custom configurations or older versions. Alternatives include using the default Jest resolver with node_modules or other custom resolvers for different package managers.","status":"active","version":"1.2.3","language":"javascript","source_language":"en","source_url":"https://github.com/arcanis/jest-pnp-resolver","tags":["javascript","jest","yarn","plugnplay","pnp"],"install":[{"cmd":"npm install jest-pnp-resolver","lang":"bash","label":"npm"},{"cmd":"yarn add jest-pnp-resolver","lang":"bash","label":"yarn"},{"cmd":"pnpm add jest-pnp-resolver","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required for resolver compatibility","package":"jest-resolve","optional":false}],"imports":[{"note":"The module is a CommonJS module and uses default export. It is not a named export.","wrong":"import { jest-pnp-resolver } from 'jest-pnp-resolver'","symbol":"jest-pnp-resolver","correct":"import 'jest-pnp-resolver'"},{"note":"Use require.resolve to get the absolute path to the resolver module.","wrong":"resolver: 'jest-pnp-resolver'","symbol":"require.resolve","correct":"resolver: require.resolve('jest-pnp-resolver')"},{"note":"The resolver configuration must be the path, not the package name.","wrong":"module.exports = { resolver: 'jest-pnp-resolver' }","symbol":"module.exports","correct":"module.exports = { resolver: require.resolve('jest-pnp-resolver') }"}],"quickstart":{"code":"// jest.config.js\nmodule.exports = {\n  resolver: require.resolve('jest-pnp-resolver')\n};","lang":"javascript","description":"Configures Jest to use the PnP resolver for resolving modules in a Yarn PnP project."},"warnings":[{"fix":"Remove resolver configuration from jest.config.js to use the built-in PnP support.","message":"As of Jest 24.4.0+, the default resolver already supports PnP, making jest-pnp-resolver unnecessary for most users.","severity":"deprecated","affected_versions":">=24.4.0"},{"fix":"Ensure your project uses Yarn PnP (i.e., has .pnp.js or .pnp.cjs file).","message":"This resolver only works with Yarn PnP (plug'n'play) installations. It will fail if used with a node_modules-based setup.","severity":"breaking","affected_versions":"all"},{"fix":"Install jest-pnp-resolver as a devDependency: yarn add -D jest-pnp-resolver","message":"Using require.resolve('jest-pnp-resolver') in jest.config.js may resolve to the wrong path if the package is not installed.","severity":"gotcha","affected_versions":"all"},{"fix":"Use transform or other Jest configuration to adjust module resolution.","message":"The resolver does not support custom module directories or moduleNameMapper patterns that rely on node_modules.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Run yarn add -D jest-pnp-resolver","cause":"Package not installed or not in node_modules.","error":"Cannot find module 'jest-pnp-resolver'"},{"fix":"Update moduleNameMapper to map to actual file paths within PnP virtual file system.","cause":"moduleNameMapper is not compatible with PnP resolution when mapping to node_modules paths.","error":"Could not locate module … mapped as …"},{"fix":"Add appropriate transform configuration in jest.config.js (e.g., babel-jest).","cause":"Usually due to missing Babel transpilation; PnP resolver alone does not handle syntax transforms.","error":"Jest encountered an unexpected token …"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}