Could not install from “Filesnodejsnode

tech2025-12-16  3

项目场景:

   npx 执行报错


问题描述:

 学习react时npx执行报错

 

npm ERR! code ENOLOCAL npm ERR! Could not install from "Files\nodejs\node_modules\npm\node_cache\_npx\14564" as it does not contain a package.json file. npm ERR! A complete log of this run can be found in: 32Z-debug.log

原因分析:

在网上看了好几个分析,说是node路径带有空格

执行 npm config get cache

得到  D:\Program Files\nodejs\node_modules\npm\node_cache

看到确实是program files 之间有空格


解决方案:

执行:npm config edit

将带空格的路径改写为:D:\Program~1\nodejs\node_modules\npm\node_cache (这是 windows 的一种路径表达方式)

或者直接执行

 npm config set cache "D:\Program~1\nodejs\node_modules\npm\node_cache"--global

最新回复(0)