创建 React App:安装时未创建 src 和 public 文件夹
Create React App: src and public folders are not creating on installation
我正在尝试创建 React 项目,但在使用 npx
或使用 yarn
时总是死机,
这是使用 npx
:
时的 CMD
部分
D:\React_Redux_Course\React Projects>npx create-react-app my_app_test --use-npm
npx: installed 98 in 50.461s
Creating a new React app in D:\React_Redux_Course\React Projects\my_app_test.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
> core-js@2.6.11 postinstall D:\React_Redux_Course\React Projects\my_app_test\node_modules\babel-runtime\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js@3.6.5 postinstall D:\React_Redux_Course\React Projects\my_app_test\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.6.5 postinstall D:\React_Redux_Course\React Projects\my_app_test\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
+ cra-template@1.0.3
+ react-scripts@3.4.1
+ react@16.13.1
+ react-dom@16.13.1
added 1624 packages from 750 contributors and audited 1628 packages in 1030.934s
58 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
并在使用 yarn
命令以及以下命令时冻结:
D:\React_Redux_Course>yarn create react-app setup-antd-first
yarn create v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-react-app@3.4.1" with binaries:
- create-react-app
Creating a new React app in D:\React_Redux_Course\setup-antd-first.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.12: The platform "win32" is incompatible with this module.
info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 14 new dependencies.
info Direct dependencies
├─ cra-template@1.0.3
├─ react-dom@16.13.1
├─ react-scripts@3.4.1
└─ react@16.13.1
info All dependencies
├─ @babel/plugin-syntax-typescript@7.10.1
├─ @babel/plugin-transform-flow-strip-types@7.9.0
├─ @babel/plugin-transform-runtime@7.9.0
├─ @babel/plugin-transform-typescript@7.10.1
├─ @babel/preset-typescript@7.9.0
├─ babel-preset-react-app@9.1.2
├─ cra-template@1.0.3
├─ eslint-config-react-app@5.2.1
├─ react-dev-utils@10.2.1
├─ react-dom@16.13.1
├─ react-error-overlay@6.0.7
├─ react-scripts@3.4.1
├─ react@16.13.1
└─ scheduler@0.19.1
Done in 212.18s.
我不知道问题到底出在哪里,可能仍然缺少需要安装的软件包或其他什么?
对于这两个,我都没有找到 src
文件夹,并且总是像我解释的那样卡住或冻结...
请给我一些建议...
已编辑:
这是冻结意思的截图:
这是项目文件夹:
首先你应该删除旧版本的 create-react-app
cli
现在执行以下操作即可创建您的应用程序。
npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
注意:
当使用正确的 create-react-app 版本时,你会看到一个额外的包 cra-template
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
虽然以前的版本显示如下:
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...
我正在尝试创建 React 项目,但在使用 npx
或使用 yarn
时总是死机,
这是使用 npx
:
CMD
部分
D:\React_Redux_Course\React Projects>npx create-react-app my_app_test --use-npm
npx: installed 98 in 50.461s
Creating a new React app in D:\React_Redux_Course\React Projects\my_app_test.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
> core-js@2.6.11 postinstall D:\React_Redux_Course\React Projects\my_app_test\node_modules\babel-runtime\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js@3.6.5 postinstall D:\React_Redux_Course\React Projects\my_app_test\node_modules\core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.6.5 postinstall D:\React_Redux_Course\React Projects\my_app_test\node_modules\core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
+ cra-template@1.0.3
+ react-scripts@3.4.1
+ react@16.13.1
+ react-dom@16.13.1
added 1624 packages from 750 contributors and audited 1628 packages in 1030.934s
58 packages are looking for funding
run `npm fund` for details
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
并在使用 yarn
命令以及以下命令时冻结:
D:\React_Redux_Course>yarn create react-app setup-antd-first
yarn create v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "create-react-app@3.4.1" with binaries:
- create-react-app
Creating a new React app in D:\React_Redux_Course\setup-antd-first.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.12: The platform "win32" is incompatible with this module.
info "fsevents@1.2.12" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@2.1.2: The platform "win32" is incompatible with this module.
info "fsevents@2.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "react-scripts > @typescript-eslint/eslint-plugin > tsutils@3.17.1" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 14 new dependencies.
info Direct dependencies
├─ cra-template@1.0.3
├─ react-dom@16.13.1
├─ react-scripts@3.4.1
└─ react@16.13.1
info All dependencies
├─ @babel/plugin-syntax-typescript@7.10.1
├─ @babel/plugin-transform-flow-strip-types@7.9.0
├─ @babel/plugin-transform-runtime@7.9.0
├─ @babel/plugin-transform-typescript@7.10.1
├─ @babel/preset-typescript@7.9.0
├─ babel-preset-react-app@9.1.2
├─ cra-template@1.0.3
├─ eslint-config-react-app@5.2.1
├─ react-dev-utils@10.2.1
├─ react-dom@16.13.1
├─ react-error-overlay@6.0.7
├─ react-scripts@3.4.1
├─ react@16.13.1
└─ scheduler@0.19.1
Done in 212.18s.
我不知道问题到底出在哪里,可能仍然缺少需要安装的软件包或其他什么?
对于这两个,我都没有找到 src
文件夹,并且总是像我解释的那样卡住或冻结...
请给我一些建议...
已编辑:
这是冻结意思的截图:
这是项目文件夹:
首先你应该删除旧版本的 create-react-app
cli
现在执行以下操作即可创建您的应用程序。
npm rm -g create-react-app
npm install -g create-react-app
npx create-react-app my-app
注意:
当使用正确的 create-react-app 版本时,你会看到一个额外的包 cra-template
Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts with cra-template...
虽然以前的版本显示如下:
Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts...