首页 > 编程知识 正文

react项目中遇到的问题,react解决了什么问题

时间:2023-05-04 17:18:11 阅读:208288 作者:587

创建react项目时遇到的报错

百度到的第一个方法:
1.执行npm install -g create-react-app全局安装
2.执行npx create-react-app myapp创建项目
结果控制台打印:

(node:18924) ExperimentalWarning: The fs.promises API is experimentalYou are running `create-react-app` 4.0.1, which is behind the latest release (4.0.2).We no longer support global installation of Create React App.Please remove any global installs with one of the following commands:- npm uninstall -g create-react-app- yarn global remove create-react-appThe latest instructions for creating a new app can be found here:https://create-react-app.dev/docs/getting-started/

之后尝试第二种方法(操作之前升级了一下npm到最新版本):
1.使用npm自带的create-react-app,不再全局使用全局安装的,第一步卸载之前(npm install -g create-react-app)下载的全局依赖,执行npm uninstall -g create-react-app
2.执行npx create-react-app myapp期待结果正确安装
结果控制台打印:

(node:19452) ExperimentalWarning: The fs.promises API is experimentalYou are running `create-react-app` 4.0.1, which is behind the latest release (4.0.2).We no longer support global installation of Create React App.Please remove any global installs with one of the following commands:- npm uninstall -g create-react-app- yarn global remove create-react-appThe latest instructions for creating a new app can be found here:https://create-react-app.dev/docs/getting-started/npm ERR! code 1npm ERR! path E:learn2021reactnpm ERR! command failednpm ERR! command C:Windowssystem32cmd.exe /d /s /c create-react-app myappnpm ERR! A complete log of this run can be found in:npm ERR! C:UserslenovoAppDataLocalnpm-cache_logs2021-02-04T01_25_30_719Z-debug.log

仍然不好用,寻找第三种解决方案
1.设置npm镜像库(之前设置成公司的镜像库了)执行npm config set registry https://registry.npm.taobao.org
2.执行npx create-react-app myapp创建项目
结果:安装成功

Success! Created myapp at E:learn2021reactmyappInside that directory, you can run several commands: npm start Starts the development server. npm run build Bundles the app into static files for production. npm test Starts the test runner. npm run eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back!We suggest that you begin by typing: cd myapp npm startHappy hacking!E:learn2021react>npm config set registry https://registry.npm.taobao.org

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。