解决npm install各种报错的6种方案 Error: Command failed: cmd.exe autoreconf -ivf以及gifsicle pre-build test fail

解决npm install各种报错的6种方案

    • 报错示例:
        • 方案零:刷新刷新 DNS 解析缓存 还有 可以尝试重启电脑
        • 方案一:使用yarn
        • 方案二:使用cnpm
        • 方案三:修改配置host
        • 方案四:这种解决其他报错比较多-修改npm源
        • 方案五: 清理缓存
    • 其他报错 Install fail! Error: EBUSY: resource busy or locked
        • 方案零:关机重启,然后再 npm install
        • 方案一:删除package-lock.json 和 node_modules,然后再 npm install
        • 方案二:运行 npm cache clean --force 或者 npm cache verify ,然后再 npm install / cnpm install。
        • 方案二:升级 npm, npm i -g npm,然后npm run dev / cnpm run dev
        • 今天就写到这里啦~

报错示例:

Error: Command failed: C:\Windows\system32\cmd.exe /s /c “autoreconf -ivf” gifsicle pre-build test failed

PS G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo> npm install
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm WARN deprecated @types/[email protected]: This is a stub types definition. svgo provides its own type definitions, so you do not need this installed.
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm WARN deprecated [email protected]: Use official tween.js package
npm WARN deprecated [email protected]: Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo\node_modules\imagemin-webpack-plugin\node_modules\gifsicle
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node lib/install.js
npm ERR! ‼ connect ETIMEDOUT 185.199.111.133:443
npm ERR!   ‼ gifsicle pre-build test failed
npm ERR!   i compiling from source
npm ERR!   × Error: Command failed: C:\Windows\system32\cmd.exe /s /c "autoreconf -ivf"
npm ERR! 'autoreconf' �����ڲ����ⲿ���Ҳ���ǿ����еij���
npm ERR! ���������ļ���
npm ERR!
npm ERR!
npm ERR!     at G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo\node_modules\bin-build\node_modules\execa\index.js:231:11
npm ERR!     at runMicrotasks ()
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm ERR!     at async Promise.all (index 0)

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2023-04-24T09_19_00_423Z-debug-0.log
PS G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo>
方案零:刷新刷新 DNS 解析缓存 还有 可以尝试重启电脑
G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo>ipconfig /flushdns

Windows IP 配置

已成功刷新 DNS 解析缓存。


方案一:使用yarn
G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo>npx yarn install
yarn install v1.22.19
warning package.json: No license field
info No lockfile found.
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
warning [email protected]: No license field
[1/4] Resolving packages...
warning [email protected]: Use official tween.js package
⠈ yallist@^4.0.0
方案二:使用cnpm
npx cnpm install
方案三:修改配置host
  • ping一下 raw.githubusercontent.com

  • 查询 raw.githubusercontent.com 这个所对应的IP,如下面的例子

  • 打开本地C:\Windows\System32\drivers\etc\hosts文件

  • 添加


185.199.108.133    raw.githubusercontent.com
185.199.108.133    gist.githubusercontent.com
185.199.108.133    cloud.githubusercontent.com
185.199.108.133    camo.githubusercontent.com
185.199.108.133    avatars0.githubusercontent.com
185.199.108.133    avatars1.githubusercontent.com
185.199.108.133    avatars2.githubusercontent.com
185.199.108.133    avatars3.githubusercontent.com
185.199.108.133    avatars4.githubusercontent.com
185.199.108.133    avatars5.githubusercontent.com
185.199.108.133    avatars6.githubusercontent.com
185.199.108.133    avatars7.githubusercontent.com
185.199.108.133    avatars8.githubusercontent.com

解决npm install各种报错的6种方案 Error: Command failed: cmd.exe autoreconf -ivf以及gifsicle pre-build test fail_第1张图片
解决npm install各种报错的6种方案 Error: Command failed: cmd.exe autoreconf -ivf以及gifsicle pre-build test fail_第2张图片
解决npm install各种报错的6种方案 Error: Command failed: cmd.exe autoreconf -ivf以及gifsicle pre-build test fail_第3张图片

方案四:这种解决其他报错比较多-修改npm源
npm --registry https://registry.npm.taobao.org install
方案五: 清理缓存
G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo>npm cache clean --force
npm WARN using --force Recommended protections disabled.

G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo>npm cache verify
Cache verified and compressed (~\AppData\Local\npm-cache\_cacache)
Content verified: 0 (0 bytes)
Index entries: 0
Finished in 0.007s

G:\code_all\my_webpack_webgl2021-5-17-dev_01\three151-demo>

其他报错 Install fail! Error: EBUSY: resource busy or locked

方案零:关机重启,然后再 npm install
方案一:删除package-lock.json 和 node_modules,然后再 npm install
方案二:运行 npm cache clean --force 或者 npm cache verify ,然后再 npm install / cnpm install。
方案二:升级 npm, npm i -g npm,然后npm run dev / cnpm run dev
今天就写到这里啦~
  • 小伙伴们,( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ我们明天再见啦~~
  • 大家要天天开心哦

欢迎大家指出文章需要改正之处~
学无止境,合作共赢

在这里插入图片描述

  • 欢迎路过的小哥哥小姐姐们提出更好的意见哇~~

你可能感兴趣的:(前端必备,npm,javascript,前端)