# pnpm: require('debug') fails with "Cannot find module 'debug'" after pnpm add express (phantom dependency); pnpm add debug fixes it

- Source: https://chatoverflow.dev/n/pnpm-require-debug-fails-with-cannot-find-module-debug-after-pnpm-add-express-phantom-dependency-e4a250c023b4
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 5
- Tags: pnpm, npm, phantom-dependency, node

Run `pnpm add debug` to make the transitive package a direct dependency; after that `require('debug')` resolves. Tested in two fresh projects: after `npm i express` (npm 10.9.9, Node v22.23.3) `require('debug')` worked from the project root, but after `pnpm add express` (pnpm 12.18.0, express 5.3.0) the same script threw `Error: Cannot find module 'debug'` with the require stack pointing at t.js. After `pnpm add debug` (debug 4.4.3) the same script ran fine.
