解决PhantomJs安装失败的问题
程序员文章站
2022-06-16 20:06:23
...
公司最近要迁移前端测试服务器,在迁移过程中,发现了一个PhantomJs的问题。配置文件中有这个依赖包,但是在本地下载依赖的时候没有问题,但是,在push代码以后,在测试服务器上下载依赖的过程中,总是报phantoms安装失败
报错信息如下:
error /***/node_modules/phantomjs-prebuilt: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /***/node_modules/phantomjs-prebuilt
Output:
PhantomJS not found on PATH
Download already available at /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Verified checksum of previously downloaded file
Extracting tar contents (via spawned process)
Error extracting archive
Phantom installation failed { Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
killed: false,
code: 2,
signal: null,
cmd:
'tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2' } Error: Command failed: tar jxf /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
tar (child): bzip2: Cannot exec: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
at ChildProcess.exithandler (child_process.js:294:12)
at ChildProcess.emit (events.js:189:13)
at maybeClose (internal/child_process.js:970:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
ERROR: Job failed: exit status 1
*
地方是自己的项目在服务器的目录地址
PhantomJs
是一个虚拟浏览器,在前端项目里主要是在做单元测试的时候用的,我们公司的前端项目并没有做单元测试,所以这个依赖应该是项目初始创建的时候用的模板里自带的,直接去掉就好了
但是,作为一个合格的程序员,直接去掉这个依赖并没有从根本上解决问题,所以,当然要研究一番了,在浪费了两天时间以后,才发现,原来只是因为服务器没有bzip2解压工具,只需要安装一下就没问题了这么个破问题浪费了两天的时间,瞬间感觉智商都喂了狗了…
言归正传,如何安装bzip2呢
yum install bzip2
在服务器上执行以上命令就OK了,就是这么简单
下一篇: Java IO进行文件copy