react查看版本和升級以及create-react-app升級


[(7條消息) react查看版本和升級以及create-react-app升級_u014678583的博客-CSDN博客_create-react-app版本](https://blog.csdn.net/u014678583/article/details/111722766)

 

查看react版本及升級

當前的react版本在你的項目中的package.json文件查看

查看react最新版本

npm info react

在第一行中有最新版本號

安裝react最新版

  1.  
    // @后面輸入版本號
  2.  
    npm install --save react@ 17.0.1

create-react-app升級

第一步需要先查看create-react-app最新版本

npm info create-react-app

接着查看你當前的create-react-app版本,如果你的版本是小於最新版本的話,那就需要繼續往下看。

  1.  
    create-react-app -V
  2.  
     
  3.  
    or 
  4.  
     
  5.  
    create-react-app --version

第二步:如果你的版本是小於上面這個最新版本的話。那么需要先卸載掉原先的舊版本: npm uninstall -g create-react-app

1、在卸載過程中如果遇到一個錯誤,這個錯誤返回並提示create-react-app,create-react-app.cmd這兩個文件的路徑時,那么就要在電腦上找到對應的文件並刪除,我的提示的路徑是在這

刪除了之后再次運行查看是否刪除成功:create-react-app -V 或 create-react-app --version

2、接着繼續安裝npm install -g create-react-app,如果在安裝過程中報如下錯誤時,那么就要找到create-react-app的文件夾位置並刪除

這兩步操作之后,繼續全局安裝npm install -g create-react-app,並查看版本號

 

3、安裝成功后,接下來就可以創建你的react項目了

  1.  
    $ yarn create react-app antd-demo
  2.  
     
  3.  
    # or
  4.  
     
  5.  
    $ npx create-react-app antd-demo

 

具體的創建項目過程和說明請看我上一篇:react create-react-app腳手架安裝及查看版本


免責聲明!

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



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