繁体   English   中英

使用 create-react-app 创建应用程序时出错

[英]Error while creating app using create-react-app

我安装了纱线,更新了节点,npm 和纱线,清除了缓存,但仍然面临相同的错误。

使用的命令:

create-react-app confusion --scripts-version=react-scripts@1.1.4

错误如下:

Creating a new React app in /home/nandini/Documents/courseraFSWD/React/confusion.

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts...

➤ YN0000: ┌ Resolution step
➤ YN0061: │ extract-text-webpack-plugin@npm:3.0.2 is deprecated: Deprecated. Please use https://github.com/webpack-contrib/mini-css-extract-plugin
➤ YN0061: │ fsevents@npm:1.2.13 is deprecated: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
➤ YN0061: │ fsevents@npm:1.2.13 is deprecated: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
➤ YN0061: │ browserslist@npm:2.11.3 is deprecated: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
➤ YN0061: │ core-js@npm:2.6.11 is deprecated: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
➤ YN0061: │ sw-precache@npm:5.2.1 is deprecated: Please migrate to Workbox: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
➤ YN0061: │ chokidar@npm:1.7.0 is deprecated: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
➤ YN0032: │ nan@npm:2.14.1: Implicit dependencies on node-gyp are discouraged
➤ YN0061: │ sw-toolbox@npm:3.6.0 is deprecated: Please migrate to Workbox: https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
➤ YN0061: │ chokidar@npm:2.1.8 is deprecated: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
➤ YN0061: │ request@npm:2.88.2 is deprecated: request has been deprecated, see https://github.com/request/request/issues/3142
➤ YN0061: │ browserslist@npm:1.7.7 is deprecated: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
➤ YN0061: │ browserslist@npm:1.7.7 is deprecated: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
➤ YN0061: │ circular-json@npm:0.3.3 is deprecated: CircularJSON is in maintenance only, flatted is its successor.
➤ YN0032: │ fsevents@npm:2.1.3: Implicit dependencies on node-gyp are discouraged
➤ YN0032: │ fsevents@npm:2.1.3: Implicit dependencies on node-gyp are discouraged
➤ YN0032: │ evp_bytestokey@npm:1.0.3: Implicit dependencies on node-gyp are discouraged
➤ YN0061: │ har-validator@npm:5.1.5 is deprecated: this library is no longer supported
➤ YN0061: │ resolve-url@npm:0.2.1 is deprecated: https://github.com/lydell/resolve-url#deprecated
➤ YN0061: │ urix@npm:0.1.0 is deprecated: Please see https://github.com/lydell/urix#deprecated
➤ YN0000: └ Completed in 46.94s
➤ YN0000: ┌ Fetch step
➤ YN0013: │ yargs-parser@npm:7.0.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:3.10.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:6.6.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:7.1.1 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ yargs@npm:8.0.2 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 11.03s
➤ YN0000: ┌ Link step
➤ YN0062: │ fsevents@patch:fsevents@npm%3A1.2.13#builtin<compat/fsevents>::version=1.2.13&hash=87eb42 The platform linux is incompatible with this module, building skipped.
➤ YN0062: │ fsevents@patch:fsevents@npm%3A2.1.3#builtin<compat/fsevents>::version=2.1.3&hash=87eb42 The platform linux is incompatible with this module, building skipped.
➤ YN0007: │ core-js@npm:2.6.11 must be built because it never did before or the last one failed
➤ YN0007: │ uglifyjs-webpack-plugin@npm:0.4.6 [85052] must be built because it never did before or the last one failed
➤ YN0000: └ Completed in 7.76s
➤ YN0000: Done with warnings in 1.1m

Aborting installation.
Unexpected error. Please report it as a bug:
Error: Cannot find module '/home/nandini/Documents/courseraFSWD/React/confusion/node_modules/react-scripts/package.json'
Require stack:
- /home/nandini/.nvm/versions/node/v14.9.0/lib/node_modules/create-react-app/createReactApp.js
- /home/nandini/.nvm/versions/node/v14.9.0/lib/node_modules/create-react-app/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
    at Function.Module._load (internal/modules/cjs/loader.js:742:27)
    at Module.require (internal/modules/cjs/loader.js:964:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at checkNodeVersion (/home/nandini/.nvm/versions/node/v14.9.0/lib/node_modules/create-react-app/createReactApp.js:514:23)
    at /home/nandini/.nvm/versions/node/v14.9.0/lib/node_modules/create-react-app/createReactApp.js:312:7
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/nandini/.nvm/versions/node/v14.9.0/lib/node_modules/create-react-app/createReactApp.js',
    '/home/nandini/.nvm/versions/node/v14.9.0/lib/node_modules/create-react-app/index.js'
  ]
}

Deleting generated file... package.json
Done.


包的版本: node -v : v14.9.0 , npm -v : 6.14.8 , yarn --version : 2.2.2 , nvm --version : 0.35.1

我使用的是 ubuntu 版本 20.04

你不需要在你的机器上全局安装 CRA,这些命令工作得很好:-

 yarn create react-app client

或者

npx create-react-app client

快乐黑客!

以下是克服此问题的步骤。

第 1 步:确保您在更新后安装了“create-react-app”。

命令: npm install -g create-react-app //g 全局安装

第 2 步:现在运行此命令以创建您的 React 应用程序。

命令: npx/yarn create-react-app 混淆

//请在执行以下命令之前检查create-react-app的版本

npx create-react-app 混淆 --scripts-version=react-scripts@1.1.4

有两种方法可以创建 React 应用程序。

  1. 全球(永久)
  2. 本地(非永久)

要全局创建 React 应用程序,请使用以下命令。

npm install -g create-react-app

导航到要放置应用程序的目录。 然后键入以下命令:

create-react-app <name-of-app>

如果你已经安装在你的机器上并且发布了新版本的 create-react-app 那么你总是需要卸载以前的版本然后重新安装它。

卸载命令: npm uninstall -g create-react-app

如果您不想永久安装,请使用npm i create-react-app 导航到 placable 目录并键入新的 react 应用程序的命令。

npx create-react-app confusionyarn create-react-app confusion

当 Create React App 发布新版本时,您可以通过以下命令对其进行升级:

npm install react-scripts@latest

对于 Ubuntu,您可以阅读https://fosslovers.com/how-to-install-reactjs-on-ubuntu-20-04/ 中的博客,他们解释了如何在 Ubuntu 20.04 中安装 react。

在命令行中试试这个

npm cache clean --force

进而:

create-react-app basics

这个会有所帮助。

您可以在此处找到所有纱线错误的列表: https : //yarnpkg.com/advanced/error-codes

似乎你必须运行yarn rebuild ,如果它不起作用也考虑做一个干净的构建(清理缓存并安装新的)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM