npm ERR: Could not install from "Files\npm-cache"


# 報錯了

```

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

```

# 分析

通過路徑可以推斷,預期路徑應該是"E:\Program Files\npm-cache"。這個路徑中包含一個空格,應該是引發程序錯誤的原因。

通過`npm config get cache` 查看 npm 的 cache 路徑設置,確實是`E:\Program Files\npm-cache`

 

# 規避

編輯路徑,在不改變路徑的情況下也能辦到。

1、npm config edit

2、將帶空格的路徑改寫為:E:\Progra~1\npm-cache (這是 windows 的一種路徑表達方式)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM