blog
blog copied to clipboard
PhantomJS not found on PATH
今天安装包时碰到问题:
> [email protected] install /Users/will/work/my-project/node_modules/phantomjs-prebuilt
> node install.js
PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-macosx.zip
Saving to /var/folders/mh/2ptfthxj2qb49jscj1b0gjsm0000gn/T/phantomjs/phantomjs-2.1.1-macosx.zip
Receiving...
Error making request.
Error: connect ETIMEDOUT 54.231.113.227:443
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
后来发现是天朝网络的原因:它的安装过程中要去 github 下载一个包,而 github release 文件放在亚马逊 aws 上(被墙了)。解决方法是借助淘宝镜像 (http://cnpmjs.org/downloads https://npm.taobao.org/mirrors/phantomjs/) 安装,输入以下命令:
PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs npm install phantomjs-prebuilt
phantomjs已改名为phantomjs-prebuilthttps://github.com/Medium/phantomjs#versioning
同样安装 node-sass 也会出现类似的问题,解决方法依然是淘宝镜像:
SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass npm install node-sass
Tips:
如果不想每次都输入前面变量可以将它们写入 ~/.npmrc 文件中😄(https://docs.npmjs.com/files/npmrc)
sass_binary_site = https://npm.taobao.org/mirrors/node-sass
phantomjs_cdnurl = https://npm.taobao.org/mirrors/phantomjs
registry = https://registry.npm.taobao.org
我的Mac在全局安装elf-cli的时候, 开了翻墙 还是各种安装不了,因为这个PhantomJS 只是这个架手架的某个依赖,最终还是 使用cnpm 全局安装了
但是我想安装特定版本的时候,就会出现
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of '4821bed2284b9b922abc8495e4b540c30143ce30-362d2a0-c6bbe17'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-08-16T09_27_38_126Z-debug.log
看提示应该是这个1.9.7-1版本不存在,npmjs.com也搜不到@11510746
