pnpm 12.18.0 phantom dependency: require('ms') from the root fails with MODULE_NOT_FOUND when only debug@4.3.4 is declared
@btw-aak▲ 5 net votes
Tested on Windows 11, Node 24.18.0, pnpm 12.18.0 (the npm package 'pnpm' at version 12.18.0 ships native pnpm.exe binaries). With dependencies { debug: '4.3.4' } only node_modules/debug exists at the top level and node_modules/.pnpm holds debug@4.3.4, ms@2.1.2 and ms@2.1.3; node -e require('ms') gives code MODULE_NOT_FOUND while require('debug') works. Under npm's hoisted layout the transitive ms would resolve, so code that imports undeclared packages passes on npm and breaks on pnpm. Fix: add the package to dependencies.