This is related to npm not being able to find a file

以下是React-Native导入第三方包时报的错误,老手请躲避。
运行命令:npm install --save martian-android-supporter

npm ERR! path F:\Git\xxx\xxx\node_modules\martian-android-supporter
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'F:\Git\xxx\xxx\node_modules\martian-android-supporter' -> 'F:\Git\xxx\xxx\node_modules\.martian-android-supporter.DELETE'
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\xxx\AppData\Roaming\npm-cache\_logs\2019-02-11T02_33_00_402Z-debug.log

对于新手可能会有点慌。出这个问题的原因就是第三方包没下载下来(可能就是因为网络不好,下载出错,所以先别慌),我的解决办法是重新运行一遍
npm install --save martian-android-supporter 该命令。
最次的解决办法就是重新 npm install 将所有的node_modules都下载一遍。
基于国内React-Native的错误资料和社区都比较次,就多手动记录记录吧。
正确下载如下

F:\Git\xxx\xxx>npm install --save martian-android-supporter
npm WARN @babel/plugin-proposal-class-properties@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-object-rest-spread@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-class-properties@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-flow@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-jsx@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-object-rest-spread@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-syntax-optional-chaining@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-arrow-functions@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-block-scoping@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-classes@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-computed-properties@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-destructuring@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-exponentiation-operator@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-flow-strip-types@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-for-of@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-function-name@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-literals@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-modules-commonjs@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-object-assign@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-parameters@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-react-display-name@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-react-jsx@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-react-jsx-source@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-regenerator@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-shorthand-properties@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-spread@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-sticky-regex@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-template-literals@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-transform-unicode-regex@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-optional-chaining@7.0.0-beta.47 requires a peer of @babel/core@7.0.0-beta.47 but none is installed. You must install peer dependencies yourself.
npm WARN react-test-renderer@16.6.3 requires a peer of react@^16.6.3 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ martian-android-supporter@1.0.0
added 1 package in 13.418s
  • 8
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
### 回答1: 这是npm出现的错误,错误代码为enoent,错误信息包括syscall spawn git、path git、errno -4058、an unknown git error occurred、this is related to npm not being able to find a file等。这可能是由于npm无法找到文件导致的错误。 ### 回答2: 该错误通常是由于 Git 未正确安装或未配置 PATH 环境变量而引起的。npm 在执行操作时需要 Git,但无法找到所需的文件或路径,因此会提示“npm err! code enoent npm err! syscall spawn git npm err! path git npm err! errno -4058 npm err! enoent an unknown git error occurred npm err! enoent this is related to npm not being able to find a file. npm err! enoent”。 解决此错误的步骤如下: 1.检查 Git 是否正确安装并配置了 PATH 环境变量。可以在命令行中输入“git --version”查看 Git 的版本号,若未正确安装,则需重新安装并确保在安装过程中正确配置 PATH 环境变量。 2.尝试使用以下命令升级 npm: ``` npm install -g npm@latest ``` 3. 如果上述方法无效,则可以尝试清除 npm 缓存并重新安装所需模块: ``` npm cache clean -f npm install ``` 如果您还是无法解决问题,请尝试在社区或论坛上寻求帮助,或与 npm 官方支持团队联系。 ### 回答3: 这个错误是由于npm在执行某些操作时无法找到git文件所致。git是一种版本控制工具,通常与npm一起使用。npm在执行下载、安装、升级包等操作时,需要依赖git进行操作。 出现这个错误的原因可能是系统中未安装git,或者git文件所在的路径被修改或删除。解决这个问题的方法是检查系统中是否已经安装git,确保git文件所在的路径正确。如果系统中未安装git,需要先去官网下载并安装git。 如果已经安装了git并且路径没问题,可以尝试清除npm的缓存,然后再执行一遍操作。具体方法是在终端中输入以下命令: npm cache clean --force 这将清除npm的缓存,然后再重新执行需要的操作。如果还是出现这个错误,还可以尝试卸载重新安装npm,以解决可能存在的损坏或冲突问题。 总之,这个错误的出现可能是多种原因造成的,需要逐一排除,找出问题所在,然后解决。这样就能让npm在操作过程中顺利地使用git,避免出现类似的问题。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值