第一次構建react前端項目

1、使用creat-react-app腳手架工具創建react項目

按照官網說明,在終端輸入命令行:npx create-react-app my-app,結果報錯如下:

npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.com/creat-react-app - Not found
npm ERR! 404
npm ERR! 404  'creat-react-app@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\lei\AppData\Roaming\npm-cache\_logs\2019-08-13T05_17_11_599Z-debug.log
Install for creat-react-app@latest failed with code 1

不明覺厲,百度發現使用直接使用此命令來構建項目各種錯誤百出,原因各異,我這個應該是沒有全局安裝creat-react-app這個腳手架工具造成的,因此我嘗試以下指令進行安裝:

npm install -g create-react-app 
create-react-app my-app

結果一路通暢無阻就安裝成功了。
不過在此過程中知道了npx的一些用法。
npm 從5.2版開始,增加了 npx 命令。npx 想要解決的主要問題,就是調用項目內部安裝的模塊。除了調用項目內部模塊,npx 還能避免全局安裝的模塊。比如,create-react-app這個模塊是全局安裝,npx 可以運行它,而且不進行全局安裝。具體的可參考:http://www.ruanyifeng.com/blo...
2、先寫到這後面再繼續。。。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章