# 報(bào)錯(cuò)了
```
E:\Code\test>npx create-react-app my-react-app
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Files\npm-cache\_npx\7920" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! E:\Program Files\npm-cache\_logs\2020-06-17T10_04_16_773Z-debug.log
Install for [ 'create-react-app@latest' ] failed with code 1
```
# 分析
通過路徑可以推斷,預(yù)期路徑應(yīng)該是"E:\Program Files\npm-cache"。這個(gè)路徑中包含一個(gè)空格,應(yīng)該是引發(fā)程序錯(cuò)誤的原因。
通過`npm config get cache` 查看 npm 的 cache 路徑設(shè)置,確實(shí)是`E:\Program Files\npm-cache`
# 規(guī)避
編輯路徑,在不改變路徑的情況下也能辦到。
1、npm config edit
2、將帶空格的路徑改寫為:E:\Progra~1\npm-cache (這是 windows 的一種路徑表達(dá)方式)
浙公網(wǎng)安備 33010602011771號(hào)