第一次构建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、先写到这后面再继续。。。

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