终端:npx create-react-app react-basic
npx:node自带工具
create-react-app 创建命令
react-basic 项目名称
创建报错提示证书过期,可以执行以下命令试试:
npm cache clean --force
npm config set strict-ssl false
创建完成后直接npm run start运行即可
运行时出现以下警告:
One of your dependencies, babel-preset-react-app, is importing the
"@babel/plugin-proposal-private-property-in-object" package without
declaring it in its dependencies. This is currently working because
"@babel/plugin-proposal-private-property-in-object" is already in your
node_modules folder for unrelated reasons, but it may break at any time.
babel-preset-react-app is part of the create-react-app project, which
is not maintianed anymore. It is thus unlikely that this bug will
ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to
your devDependencies to work around this error. This will make this message
go away.
解决方式: npm install --save-dev @babel/plugin-proposal-private-property-in-object
网友评论