fix: add typescript as dependency to resolve knip peer dep in npx/dlx environments#17
Conversation
knip requires typescript >=5.0.4 as a peer dependency for its Astro plugin. When react-doctor is executed via npx or pnpm dlx, the isolated environment does not have access to the host project's node_modules, causing ERR_MODULE_NOT_FOUND for typescript. Adding typescript explicitly as a dependency ensures it is always available when react-doctor is installed. Fixes: ERR_MODULE_NOT_FOUND: Cannot find package 'typescript' imported from knip/dist/plugins/astro/resolveFromAST.js
|
@olivermontes is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
|
lgtm |
|
not working on version 0.0.17 ➜ web git:(main) ✗ npx -y react-doctor@latest . Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'typescript' imported from .npm/_npx/81e833f6d16d6127/node_modules/knip/dist/PrincipalFactory.js Node.js v24.8.0 still getting the same issue |
For me is working @ameetmadan, maybe i
|
ok, is not publish yet https://www.npmjs.com/package/react-doctor?activeTab=dependencies or command npm view react-doctor@0.0.17 dependencies next release? @aidenybai |

Problem
When running
npx -y react-doctor@latest .orpnpm dlx react-doctor@latest ., the following error occurs:Root Cause
knipdeclarestypescript >=5.0.4as a required peer dependency for its Astro plugin. Whenreact-doctoris executed vianpxorpnpm dlx, it runs in an isolated cache directory that does not have access to the host project'snode_modules. As a result,typescriptcannot be resolved at module load time.Fix
Add
typescriptas an explicit dependency inpackages/react-doctor/package.json, matching the range required by knip (>=5.0.4 <7). This ensurestypescriptis always installed alongsidereact-doctorin any environment.Testing
Before fix:
After fix: react-doctor runs correctly since typescript is bundled as a direct dependency.