【问题标题】:Create React App not installing, showing an error and aborting installation创建 React App 未安装,显示错误并中止安装
【发布时间】:2019-03-23 17:46:55
【问题描述】:

我重新安装了 Node.js 和 Yarn。现在我收到此错误。

我的环境信息是:

节点:v8.12.0

NPM:6.4.1

纱线:1.10.1

操作系统:Windows 10

PS C:\Users\mdbel\Desktop\Project\redux> npx create-react-app learnredux

Creating a new React app in C:\Users\mdbel\Desktop\Project\redux\learnredux.

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

yarn add v1.10.1
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.1.tgz: Request failed \"404 Not Found\"".
info If you think this is a bug, please open a bug report with the information provided in "C:\\Users\\mdbel\\Desktop\\Project\\redux\\learnredux\\yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom react-scripts --cwd C:\Users\mdbel\Desktop\Project\redux\learnredux has failed.

Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.

【问题讨论】:

  • C:\Users\you\.npmrc 中删除.npmrc 将解决此问题。

标签: node.js reactjs npm create-react-app yarnpkg


【解决方案1】:

一旦你通过运行清理了纱线缓存:

yarn cache clean

随后调用:

npx create-react-app your-app

会起作用的。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题并通过以下方式解决了它:

    安装最新版本的 node、npm 和 yarn。

    npm install -g npm@latest
    nvm install node
    npm install -g yarn

    nvm 安装 Node.js 而 npm 管理包。

    【讨论】:

    • 这对我来说效果最好。 npx create-react-app 已经没有问题了。谢谢!
    • 这是正确答案。 create-react-app 需要 Node >= 8.10 and npm >= 5.6
    【解决方案3】:

    我通过从C:\Users\yourUserName\ 中删除.yarnrc 文件解决了这个问题

    【讨论】:

      【解决方案4】:

      C:\Users\you\.npmrc中删除.npmrc也可以解决问题。

      【讨论】:

        【解决方案5】:

        更新到最新稳定版本的纱线并删除 AppData 文件夹中的纱线缓存文件夹解决了我的问题 C:\Users\test\AppData\Local\Yarn

        【讨论】:

          【解决方案6】:

          我在使用npx 时遇到了同样的问题,并且能够通过以下步骤解决此问题:

          • 升级到最新的纱线版本:$ npm i @yarn@latest
          • 删除 node_modules 文件夹
          • 删除 yarn.lock(如果存在)。
          • 从您的用户文件夹中删除 .npmrc。

          如果问题仍然存在,您可以改用 yarn 命令:$ yarn create react-app learnredux

          yarn create 适用于 Yarn 0.25+

          【讨论】:

          • C:\Users\you\.npmrc 中删除.npmrc 解决了我的问题。
          【解决方案7】:

          我遇到了同样的问题,然后我尝试了以下命令并解决了我的问题

          npm cache clean --force
          

          上面的命令没有解决你的问题,然后试试下面的。

          npm init -y
          npx create-react-app your-app-name
          

          【讨论】:

            【解决方案8】:

            我在我的 Mac 上遇到了同样的错误。

            我刚刚从 Node.js 网站重新下载了安装程序。这应该重新安装所有依赖项并确保所有路径都有效。

            https://nodejs.org/en/download/

            【讨论】:

              【解决方案9】:

              我还通过从

              安装最新版本的节点解决了我的问题

              https://nodejs.org/en/download/

              然后我在命令下面运行

              npm install -g create-react-app
              

              在终端 后跟“create-react-app”或“create-react-app”。如果您已经在文件夹中。

              【讨论】:

                【解决方案10】:

                这可能对 Linux 操作系统有所帮助

                sudo npm install -g npm@latest
                npm install node
                npm init
                npm install -g yarn
                yarn cache clean
                npx create-react-app my-app
                

                【讨论】:

                  【解决方案11】:

                  试试这个!

                  npm install -g npm@latest  
                  
                  npm install node
                  
                  
                  npm install -g yarn
                  
                  
                  npx create-react-app appname
                  
                  cd firstapp
                  
                  yarn start
                  

                  【讨论】:

                    【解决方案12】:

                    将节点模块更新到适合我的版本 13.12.0

                    https://nodejs.org/es/download/current/

                    【讨论】:

                    • 这有什么帮助?
                    【解决方案13】:

                    是的,我有同样的问题,但在卸载 yarn 并使用最新版本更新节点后无法解决。

                    另外,请确保您已安装

                    npm i -g create-react-app
                    

                    更新包后。

                    清理缓存也让它没有错误,这肯定会工作

                    【讨论】:

                      【解决方案14】:

                      Windows 用户的最佳方法是更新您的纱线 如果您使用 npx 并得到错误而不是 update yarn 然后使用 npx 我在 Windows 8.1 中遇到了同样的错误,然后我更新了 yarn,它解决了我的问题

                      Npm I yarn@latest
                      npx creat-react-app  app name
                      

                      【讨论】:

                      • 请尽量使用可运行命令行的代码块或一般代码
                      【解决方案15】:

                      我遇到了同样的问题。似乎当npmnode 安装被破坏时会发生这种情况。但是,有时清除缓存不起作用。我不仅要卸载,还要删除/清除系统上的所有 npmnode 文件,然后重新安装。

                      删除节点和 npm

                      sudo rm -rf /usr/local/lib/node_modules
                      sudo rm -rf ~/.npm
                      
                      sudo apt remove --purge npm
                      sudo apt remove --purge node
                      sudo apt remove --purge nodejs
                      

                      通过运行检查 npm 和节点是否被删除:which nodewhich npm 如果您仍然看到一些文件夹,请尝试使用以下方法删除它们:

                      sudo apt-get remove nodejs
                      sudo apt-get remove npm
                      

                      更新系统,以防万一

                      sudo apt-get update
                      

                      安装节点和 npm

                      sudo apt-get install nodejs
                      sudo apt-get install npm
                      

                      检查安装

                      npm -v
                      node -v
                      

                      注意:此处的步骤涉及删除现有模块并将它们重新放回原处。我还必须使用程序和功能(适用于 Windows)手动卸载 nodejs。

                      【讨论】:

                        【解决方案16】:

                        我不小心隐藏了 .yarnrc 文件并导致了问题。

                        【讨论】:

                          【解决方案17】:

                          将节点重新安装到最新版本对我有用。

                          https://nodejs.org/en/download/

                          【讨论】:

                            【解决方案18】:

                            我遇到了同样的问题。您可以使用 npm 代替 yarn 来创建应用程序。只需添加--use-npm 标志即可:

                            npx create-react-app app --use-npm
                            

                            【讨论】:

                              猜你喜欢
                              • 2020-10-29
                              • 1970-01-01
                              • 2020-05-28
                              • 2015-11-01
                              • 1970-01-01
                              • 1970-01-01
                              • 2022-07-06
                              • 1970-01-01
                              • 2021-12-06
                              相关资源
                              最近更新 更多