You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Yarn PnP: require.cache and require.extensions are undefined in dependencies (regression in nodejs v22.22.3) #7234
Under Yarn PnP on Node.js v22.22.3 through v22.23.1, the require.extensions and require.cache properties are undefined in the require function that packages receive. This breaks tools like webpack-cli (via rechoir) and any other packages that access these standard CommonJS properties.
To reproduce
#!/usr/bin/env bash
#
# Save this script to a file named `repro.sh`, then run it:
#
# bash repro.sh
#
# Without an argument, the script creates `node-yarn-pnp-repro` in the
# directory from which the script is run.
#
# Or choose the directory where the test project will be created:
#
# bash repro.sh ./my-pnp-repro
set -euo pipefail
repro_dir="${1:-node-yarn-pnp-repro}"
if [[ -e "$repro_dir" ]]; then
echo "Directory already exists: $repro_dir" >&2
exit 1
fi
mkdir "$repro_dir"
cd "$repro_dir"
echo "Reproduction directory: $PWD"
cat > package.json <<'EOF'
{
"name": "node-yarn-pnp-repro",
"private": true,
"packageManager": "[email protected]",
"dependencies": {
"autoprefixer": "10.4.2",
"css-loader": "7.1.4",
"postcss": "8.4.49",
"postcss-loader": "8.2.1",
"style-loader": "4.0.0",
"tailwindcss": "3.4.15",
"webpack": "5.108.1",
"webpack-cli": "5.1.4"
}
}
EOF
cat > .yarnrc.yml <<'EOF'
nodeLinker: pnp
enableGlobalCache: false
EOF
cat > tailwind.config.js <<'EOF'
module.exports = {
content: ['./src/**/*.html'],
theme: { extend: {} },
plugins: [],
};
EOF
cat > postcss.config.js <<'EOF'
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
};
EOF
mkdir src
cat > src/style.css <<'EOF'
@tailwind base;
@tailwind components;
@tailwind utilities;
EOF
cat > src/index.html <<'EOF'
<div class="text-red-500">hi</div>
EOF
cat > webpack.config.js <<'EOF'
const path = require('path');
module.exports = {
mode: 'production',
entry: './src/style.css',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.css$/,
use: ['style-loader', 'css-loader', 'postcss-loader'],
},
],
},
};
EOF
corepack yarn install
corepack yarn webpack
changed the title [-]Yarn PnP: `require.cache` and `require.extensions` are undefined in dependencies (regression in v22.22.3)[/-][+]Yarn PnP: `require.cache` and `require.extensions` are undefined in dependencies (regression in nodejs v22.22.3)[/+]on Jul 26, 2026
Activity
[-]Yarn PnP: `require.cache` and `require.extensions` are undefined in dependencies (regression in v22.22.3)[/-][+]Yarn PnP: `require.cache` and `require.extensions` are undefined in dependencies (regression in nodejs v22.22.3)[/+]PnP: Ensure require.cache and require.extensions are populated in dep…