簡體   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