【问题标题】:Getting the following error while executing expo init command执行 expo init 命令时出现以下错误
【发布时间】:2019-08-22 08:41:44
【问题描述】:
Installing dependencies...
npm WARN deprecated core-js@1.2.7: core-js@<2.6.5 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
npm ERR! path git
npm ERR! code ENOENT
npm ERR! errno ENOENT
npm ERR! syscall spawn git
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t ssh://git@github.com/expo/react-native-maps.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\SAMSUNG\AppData\Roaming\npm-cache\_logs\2019-04-01T08_16_06_470Z-debug.log
Process exited with non-zero code: 1
Set EXPO_DEBUG=true in your env to view the stack trace.

【问题讨论】:

    标签: javascript node.js react-native npm expo


    【解决方案1】:

    请确保您拥有git installed。 NPM 需要 git 来安装一些包。您可以通过以下方式检查 git 是否安装:

    git --version
    

    如果是这样,根据reported issue,删除并重新安装 node_modules 应该会有所帮助:

    rm -rf node_modules && npm install
    

    您也可以尝试使用yarn解决问题:

    brew install yarn
    npm uninstall -g create-react-native-app
    yarn global add create-react-native-app
    

    【讨论】:

      【解决方案2】:

      这似乎是core-js 版本问题。

      package.json,检查"expo-core": "version",如果它低于错误:您更正版本以适应错误。

      rm -rf node_modules &amp;&amp; npm install

      npm install -g expo-cli
      

      完成后,尝试运行一个新的expo init

      【讨论】:

        【解决方案3】:

        只需检查您的系统上是否安装了 git。否则,下载它

        从这里安装 git - https://git-scm.com/downloads

        您的问题将得到解决干杯! :)

        【讨论】:

        • 检查 git,如果不存在安装它已经在 4 月 1 日here 的答案中作为建议给出,包括安装说明的链接。请只添加带来新建议的答案。
        【解决方案4】:

        默认的 expo-template-blank 模板将 react-native 指向它们自己的 Github 存储库 - 从 Github 存储库安装可能会导致 NPM 由于各种原因挂起或出错。

        要解决此问题ctrl-c 以在项目搭建完成后继续安装依赖项时中断初始化,请编辑 package.json 以从 NPM 注册表安装 react-native - 例如,这是我的依赖项的外观:

         "dependencies": {
            "expo": "^35.0.1",
            "react": "^16.8.3",
            "react-dom": "^16.8.3",
            "react-native": "^0.59.10"
        //...
        

        然后手动执行npm i 安装依赖即可享受。

        【讨论】:

          【解决方案5】:

          这显示你没有安装 git。 您可以按照上面的任何答案使其在本地运行。 但是,如果您在部署节点应用程序时遇到此问题,请检查您用于部署的节点映像。如果是 node: alpine 那么你会得到这个错误。

          要修复它,您可以使用 node:carbon 图像。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-11-15
            • 2023-01-08
            • 2017-01-19
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 2020-02-24
            相关资源
            最近更新 更多