I am doing the Banking app course on JavaScript Mastery’s YouTube channel.
At 9:52. when I enter the following command:
npx shadcn@latest init
I get this error message:
PS F:JavaScript Masteryjsm_banking> npx shadcn@latest
node:internal/modules/esm/resolve:215
const resolvedOption = FSLegacyMainResolve(packageJsonUrlString, packageConfig.main, baseStringified);
^
Error: Cannot find package 'C:UsersMYAppDataLocalnpm-cache_npxd66c5096c7023bfbnode_moduleshttps-proxy-agentdistindex.js' imported from C:UsersMYAppDataLocalnpm-cache_npxd66c5096c7023bfbnode_modulesshadcndistindex.js
at legacyMainResolve (node:internal/modules/esm/resolve:215:26)
at packageResolve (node:internal/modules/esm/resolve:841:14)
at moduleResolve (node:internal/modules/esm/resolve:927:18)
at defaultResolve (node:internal/modules/esm/resolve:1169:11)
at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:540:12)
at ModuleLoader.resolve (node:internal/modules/esm/loader:509:25)
at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
at link (node:internal/modules/esm/module_job:95:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
How can I fix this issue?
1
I am facing this exact issue today, it comes out of nowhere whenever I try to add a new component. Found this solution, didn’t work for me, but maybe it might work for you
The solution that worked for me at the end of the day was running the following commands:
- npm cache clean –force
- npx clear-npx-cache
- npx shadcn add component_name (don’t add @latest)