yarn装置报错
报错信息
error C:\Users\Acer\Desktop\react\node_modules\gifsicle: Command failed.Exit code: 1Command: node lib/install.jsArguments:Directory: C:\Users\Acer\Desktop\react\node_modules\gifsicleOutput:‼ getaddrinfo ENOENT raw.githubusercontent.com ‼ gifsicle pre-build test failed i compiling from source × Error: Command failed: C:\WINDOWS\system32\cmd.exe /s /c "autoreconf -ivf"'autoreconf' ���������ⲿ������ǿ����ij���
网上百度,发现比拟少人遇到这个问题,感觉应该是本人本地环境有些问题,那有可能是本人本地环境有问题,而后就狐疑是本人装的yarn版本或者node版本不对,或者本人网络不好之类的,瞎猜,还从新把包删了重装之类,都没用,无头苍蝇。
其实问题还是本人教训太少了,记录一下,不便本人当前排查bug
首先程序报错了,不要慌,咱们应该先看报错信息,看下面信息说的是C:\Users\Acer\Desktop\react\node_modules\gifsicle这个文件夹上面的lib/install.js这个脚本外面有命令执行失败了,具体什么问题还不分明,所以应该去找到这个文件去看一下
install.js
'use strict';const path = require('path');const binBuild = require('bin-build');const log = require('logalot');const bin = require('.');(async () => { try { await bin.run(['--version']); log.success('gifsicle pre-build test passed successfully'); } catch (error) { log.warn(error.message); log.warn('gifsicle pre-build test failed'); log.info('compiling from source'); const config = [ './configure --disable-gifview --disable-gifdiff', `--prefix="${bin.dest()}" --bindir="${bin.dest()}"` ].join(' '); try { await binBuild.file(path.resolve(__dirname, '../vendor/source/gifsicle-1.92.tar.gz'), [ 'autoreconf -ivf', config, 'make install' ]); log.success('gifsicle built successfully'); } catch (error) { log.error(error.stack); // eslint-disable-next-line unicorn/no-process-exit process.exit(1); } }})();
从这个文件中找一下,看看有没有本人能看懂,或者感觉有问题的,有的,就是这个gifsicle pre-build test failed,终端报错信息中就有这个,所以应该是bin.run(['--version'])这行代码有问题导致产生了这个报错,持续找,bin是require('.')引入进来的,对应的应该是同目录下的index.js,所以应该去看index.js文件的内容
index.js
'use strict';const path = require('path');const BinWrapper = require('bin-wrapper');const pkg = require('../package.json');const url = `https://raw.githubusercontent.com/imagemin/gifsicle-bin/v${pkg.version}/vendor/`;module.exports = new BinWrapper() .src(`${url}macos/gifsicle`, 'darwin') .src(`${url}linux/x86/gifsicle`, 'linux', 'x86') .src(`${url}linux/x64/gifsicle`, 'linux', 'x64') .src(`${url}freebsd/x86/gifsicle`, 'freebsd', 'x86') .src(`${url}freebsd/x64/gifsicle`, 'freebsd', 'x64') .src(`${url}win/x86/gifsicle.exe`, 'win32', 'x86') .src(`${url}win/x64/gifsicle.exe`, 'win32', 'x64') .dest(path.join(__dirname, '../vendor')) .use(process.platform === 'win32' ? 'gifsicle.exe' : 'gifsicle');
这个文件的意思应该是依据不必的环境零碎下载不同的一个可执行文件,我的电脑是windows,文件应该放在上一层的vendor文件夹下,命名为gifsicle.exe,而后执行后续操作,一步一步来,首先去看文件下载下来了吗,去看vendor文件夹,没有这个文件,证实这步出错了,所以这个时候咱们的思路应该是看为啥没下载下来,这个时候能够回头看下报错信息,看看有没有有用信息,第一行报错信息是getaddrinfo ENOENT raw.githubusercontent.com,getaddrinfo是获取地址信息,ENOENT是大写的,像是一个专业术语,所以间接百度,应该有的,这个是一个缩写,全称是Error No Entry,没有这个的目录的意思,再联合前面那个网址,所以应该是脚本运行的时候没有找到正确的下载地址,有可能是被墙了,这个时候思考代理的问题,我电脑是开了代理的,然而我yarn如同没设置代理,所以能够试着给yarn设置代理
$ yarn config set proxy http://127.0.0.1:7890/
从新运行yarn装置依赖没有再呈现什么问题