使用react前需要配置下node环境,可以根据这个网页来操作
完成配置并测试可成功创建react项目后
使用命令安装vite或用vite创建vue3项目,会导致报错
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:…………
网上搜了半天,可能是node路径带有空格导致的
所以推荐使用这个网页的办法解决
推荐使用网页里的方法1
执行:npm config edit
会弹出txt文件,把文件里前几行中 cache的路径改写为
D:\Program~1\nodejs\node_modules\npm\node_cache (这是 windows 的一种路径表达方式,根据自己实际路径改写)