reactjsnode.jstypescriptnpmbabeljs

How do I fix a MODULE_NOT_FOUND error for a module that I don't manually import?


I was just trying to install a shadcn package and was met with this extremely strange error:

 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command "cache" not found
node:internal/modules/cjs/loader:1275
  const err = new Error(`Cannot find module '${request}'`);
              ^

Error: Cannot find module '/Users/XXX/Library/Caches/pnpm/dlx/hx67qbkz3shxeflxwe2je2aqw4/193af67f081-15278/node_modules/.pnpm/@babel+generator@7.26.3/node_modules/@jridgewell/gen-mapping/dist/gen-mapping.umd.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1275:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1264:15)
    at resolveExports (node:internal/modules/cjs/loader:638:14)
    at Function._findPath (node:internal/modules/cjs/loader:737:31)
    at Function._resolveFilename (node:internal/modules/cjs/loader:1225:27)
    at Function._load (node:internal/modules/cjs/loader:1064:27)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
    at Module.require (node:internal/modules/cjs/loader:1325:12)
    at require (node:internal/modules/helpers:136:16) {
  code: 'MODULE_NOT_FOUND',
  path: '/Users/XXX/Library/Caches/pnpm/dlx/hx67qbkz3shxeflxwe2je2aqw4/193af67f081-15278/node_modules/.pnpm/@babel+generator@7.26.3/node_modules/@jridgewell/gen-mapping'
}

Node.js v23.3.0

For reference, this was the command I tried to run that caused this error:

pnpm dlx shadcn@latest add accordion

I tried to run these commands to remedy this:

pnpm store prune
rm -rf node_modules pnpm-lock.yaml
pnpm install

I also tried to manually add the package that the error made reference to, I tried to both add it as a dev-dependency, and as a regular package, with:

pnpm add @jridgewell/gen-mapping
pnpm add -D @jridgewell/gen-mapping

Nothing I tried seemed to do the trick, so any help would be greatly appreciated!


Solution

  • fixed it by downgrading manually using
    npm i @jridgewell/gen-mapping@0.3.4 --force