【问题标题】:Error while installing create-react-app globally using npm使用 npm 全局安装 create-react-app 时出错
【发布时间】:2020-04-19 17:45:26
【问题描述】:

我无法使用 NPM 安装 react js。我收到以下错误。 您的环境已设置为使用 Node.js 12.3.1 (ia32) 和 npm。

C:\Users\User>npm install create-react-app -g

npm 错误!代码 UNABLE_TO_VERIFY_LEAF_SIGNATURE

npm 错误!错误号 UNABLE_TO_VERIFY_LEAF_SIGNATURE

npm 错误!对https://registry.npmjs.org/create-react-app 的请求失败,原因:

无法验证第一个证书

npm 错误!可以在以下位置找到此运行的完整日志:

npm 错误! C:\Users\User\AppData\Roaming\npm-cache_logs\2019-12-14T05_54_58_7

16Z-debug.log

我来自印度,我没有使用任何公司防火墙或 VPN。

【问题讨论】:

  • 检查这个答案,之后但是, stackoverflow.com/a/59515134/7692076我不知道这是否能解决你的问题,但试试吧。
  • 也许检查以确保您以“管理员身份”打开了终端。我在尝试全局安装软件包时遇到了节点安装问题。 (虽然这对我来说通常会失败并出现不同的错误)
  • 其证书无效。试试 npm config set strict-ssl false
  • 请设置环境变量,然后全局安装npm
  • @GovindSoni 请您详细说明一下。我对 NPM 很陌生。这就是为什么我不知道什么是环境变量。

标签: reactjs npm


【解决方案1】:

你可以试试npx create-react-app ${your project name}

【讨论】:

    【解决方案2】:

    我在命令行中运行了以下命令并为我工作:

    npm config set strict-ssl false
    

    虽然这不是一个好主意。

    运行此命令再次打开它:

    npm config set strict-ssl true
    

    【讨论】:

      【解决方案3】:

      下载 Node.js 存档

      成功安装 NodeJS 后,我们可以开始使用 npm 在其上安装 React。您可以通过两种方式安装 ReactJS。

      - Using webpack and babel.
      - Using the create-react-app command.
      

      但我要告诉你的是使用 create-react-app 命令:

      - Instead of using webpack and babel you can install ReactJS more simply by installing create-react-app.
      
      Browse through the desktop and install the Create React App using command prompt as shown below: 
      
      Step 1: go to your specific directory and run below commands inside the folder like as below:
      Step 2: d:\reactproject\>npx create-react-app my-app
      Step 3: cd my-app
      Step 4: npm start
      

      【讨论】:

        【解决方案4】:

        检查您的日期是否正确。 如果没有运行,请重试:

        sudo date --set="2015-09-30 10:05:59.990"
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2020-01-21
          • 2020-11-13
          • 1970-01-01
          • 1970-01-01
          • 2021-03-16
          • 2019-01-23
          相关资源
          最近更新 更多