[英]Why create-react-app doesn't create new app
我使用 npm 在 Node JS 上安裝了最新版本,但無法運行 create-react-app。 出現以下問題:
Creating a new React app in C:\wamp64\www\bob.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '....tgz"}},"2.3.4":{"nam'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache_logs\2019-02-26T21_21_48_727Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\wamp64\www
Done.
版本:
Node v10.15.1
npm 6.7.0
有人可以幫忙嗎?
運行 npm cache clean --force 后
發生另一個錯誤:
$ create-react-app 鮑勃
Creating a new React app in C:\Users\Ivana\bob.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
npm ERR! Unexpected end of JSON input while parsing near '...,"@babel/plugin-synta'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ivana\AppData\Roaming\npm-cache\_logs\2019-02-27T09_18_28_856Z-debug.log
Aborting installation.
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.
Deleting generated file... package.json
Deleting bob/ from C:\Users\Ivana
Done.
來自https://github.com/facebook/create-react-app#creating-an-app
npx create-react-app my-app
(npx 隨 npm 5.2+ 及更高版本一起提供)
但是你用
create-react-app my-app
如果您使用 npm 5.1 或更早版本,則不能使用 npx。 相反,全局安裝 create-react-app:
npm install -g create-react-app
現在你可以運行:
create-react-app my-app
經過幾次搜索,我發現了這個:
如果您之前已經通過 npm install -g create-react-app 全局安裝了 create-react-app,我們建議您使用 npm uninstall -g create-react-app 卸載包,以確保 npx 始終使用最新版本。
所以如果你安裝了 create-react-app
npm -g install create-react-app
趕緊跑 :
npm -g uninstall create-react-app
npx create-react-app
它應該做的工作
我能夠解決這個問題,
跑步
npm cache clean --force
然后
npm create-react-app my-app
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.