項目場景:
npx 執行報錯node
問題描述:
學習react時npx執行報錯react
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
執行 npm config get cachejson
獲得 D:\Program Files\nodejs\node_modules\npm\node_cachewindows
看到確實是program files 之間有空格學習
解決方案:
執行:npm config editthis
將帶空格的路徑改寫爲:D:\Program~1\nodejs\node_modules\npm\node_cache (這是 windows 的一種路徑表達方式)spa
或者直接執行debug
npm config set cache "D:\Program~1\nodejs\node_modules\npm\node_cache"--globalcode