【React】当npx create-react-app my-app失败时~ 解决方案:处理PC用户名中的空白 ~
从错误内容来看,原因似乎是用户名中有空格。
错误消息
当用户的用户名为AAA BBB时
C:\Users\AAA BBB>npx create-react-app my-app
Error: EPERM: operation not permitted, mkdir 'C:\Users\AAA'
TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
... (省略)
C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:98
var doExit = npm.config.loaded ? npm.config.get('_exit') : true
^
TypeError: Cannot read property 'loaded' of undefined
at exit (C:\Program Files\nodejs\node_modules\npm\lib\utils\error-handler.js:98:27)
... (省略)
Install for create-react-app@latest failed with code 7
解决办法 – fǎ
stack overflow: https://stackoverflow.com/questions/56508244/%E5%AE%89%E8%A3%85create-react-app%E6%8A%A5%E9%94%99%E4%BB%A5%E4%BB%A7%E7%AC%AC7%E4%BB%A3%E7%A0%81%E7%9A%84-methoderror
1. npm cache clean --force
2. npm install create-react-app --force
3. npm fund
4. npx create-react-app <app-name>
GitHub –> GitHub目录
在GitHub上有一个问题被提交了。
https://github.com/facebook/create-react-app/issues/6512