Installing PhantomJS on Mac - installation

I'm trying to install PhantomJS on my Mac (Yosemite).
I did the following:
npm install phantomjs
Then I did:
npm install phantomjs-prebuilt
Both of which appear in my node_modules. But when I try to run phantomjs --versionI get
-bash: phantomjs: command not found
Also tried installing the binary from the downloads website, but nothing. What am I missing? End goal is to use casperjs but currently casper is asking
Fatal: [Errno 2] No such file or directory; did you install phantomjs?
I thought I did....?

If you are using Homebrew, you can type:
brew tap homebrew/cask
brew cask install phantomjs

Download phantomjs latest version (ex: phantomjs-2.1.1-macosx.zip) from http://phantomjs.org/download.html
Extract it to some path(ex: ~/Desktop/phantomjs-2.1.1-macosx)
Run this command on terminal -
sudo ln -n ~/Desktop/phantomjs-2.1.1-macosx/bin/phantomjs /usr/local/bin/
Launch phantomjs from the terminal by command: phantomjs
Check phantomjs version by command: phantomjs -v
Check the phantomjs path by command: which phantomjs

The accepted answer is outdated. On Mac, using Homebrew, type:
brew tap homebrew/cask
brew cask install phantomjs
The first step may not be necessary for some MacOS versions.
For newer versions of cask (2021 and later), use
brew install --cask phantomjs

You need to add phantomjs binary to your PATH. You can do this either by modifying the environment variable or by symlinking the binary to for example /usr/local/bin
For example, if you want to symlink the binary:
cd $HOME
curl -O https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
ln -s $HOME/phantomjs-2.1.1-macosx/bin/phantomjs /usr/bin/phantomjs
or if you want to modify the PATH environment variable:
cd $HOME
curl -O https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-macosx.zip
and add this line to this file: ~/.bash_profile:
export PATH=$HOME/phantomjs-2.1.1-macosx/bin:$PATH
and then run:
source ~/.bash_profile

Shouldn't you be installing phantomjs globally?
npm install -g phantomjs
Since you are installing it locally, the command -
phantomjs -v
would not work everywhere.
You can check the difference between local install and global install here: https://docs.npmjs.com/cli/install

After a lot of digging I found that on on High-Sierra old versions of phantomjs (<2.0) would not work.
Also, the zip file via the phantomjs download page is a faulty one.
If you need a new phantom, just go to this page and download phantomjs 2.1.1 (or later).

for Mac BigSur
brew tap homebrew/cask
brew install --cask phantomjs

Related

Unable to install packages via npm; can only use homebrew

I a trying to install some cli tools to use globally. Running the install command via npm never works - I get command not found [package] whenever I check [package] -v. I have tried this with netlify-cli, firebase-tools, and heroku.
However, when I install heroku via homebrew (brew tap heroku/brew && brew install heroku) it seemed to work fine. The version info showed up on heroku -v.
If it's relevant, I'm using MacOS 13.0, and ohmyzsh on iTerm2. I tried the built-in terminal (which also runs zsh) but had no luck.
How can I reliably use npm in order to install tools?

Unable to UnInstall ChromeDriver 2.45

I am trying to uninstall ChromeDriver 2.45 and use version 2.36 for a python package that requires 2.36.
I have run every command uninstall command I can think of shown (pip, pip3, brew, npm) in the screenshot. I have even run all the same commands in the python virtual environment.
I cannot get 2.45 to leave the system.
How do I uninstall 2.45??
If you downloaded the binary from Google, the install is a simple copy of the binary into (usually) /usr/local/bin.
To uninstall, remove the binary :
$ whereis chromedriver
/usr/local/bin/chromedriver
$ rm /usr/local/bin/chromedriver

Fastlane command not found

I am trying to install fastlane. I have Xcode installed. I installed fastlane using the command sudo gem install fastlane. I now go into my project folder and type fastlane init and get the error:
-bash: fastlane: command not found.
I see that fastlane is installed and can see it here
/Users/username/.gem/ruby/2.0.0/gems/fastlane-1.70.0/bin
on my Mac.
I tried adding this to my PATH, but I still get the same error. My path is
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:./Users/username/.gem/ruby/2.0.0/gems/
What am I missing here?
Add the following line to your bash profile:
export PATH="$HOME/.fastlane/bin:$PATH"
You can either close the terminal session and restart it or run source ~/.bash_profile to load your configuration and then you can go so you start using fastlane 🚀
I got run into similar issue last week. I installed fastlane using homebrew on mac, but it was showing the same error.
I tried installing it using Ruby and it worked like a charm. Here is the command.
sudo gem install fastlane -NV
Also seems like you have not installed command line tools for xcode.
Install them using xcode-select --install
I met this issue because of installing zsh, the below two steps solve my problem:
open ~/.zshrc
save path
2.1 if you install fastlane with Homebrew
Copy export PATH="$HOME/.fastlane/bin:$PATH" on the bottom line.
2.2 if you install fastlane with RubyGems
Copy export PATH="/usr/local/bin/fastlane"" on the bottom line.
save upon file and try fastlane init, everything is OK!
In the terminal type cd ~/ to go to your home folder
Type touch .bash_profile to create your new empty file
Type open -e .bash_profile to open the file
Enter export PATH="$HOME/.fastlane/bin:$PATH" and save
Restart terminal (not sure needed?)
Here is what I installed on Mac - from scratch
Removed from brew install
brew uninstall fastlane
brew install rbenv
Install Ruby version 2.6.6
rbenv install 2.6.6
Set the Ruby version in global
rbenv global 2.6.6
Add Ruby to the PATH
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
Install bundler
gem install bundler
Install fastlane
bundle add fastlane
fastlane is in cask now. You can install it using
brew cask install fastlane
Now you need to export PATH so that your shell can find fastlane
do
export PATH="$HOME/.fastlane/bin:$PATH"
If that doesn't work, try this
export PATH="$HOME/.fastlane/bin/fastlane_lib:$PATH"
Make sure you add it to ~/.profile, ~/.zshrc or ~/.bashrc for future
If you are working on local machine then add following to you .bash_profile
export PATH="$HOME/.fastlane/bin:$PATH"
If you are working on Jenkins then this worked for me 😎
Under Jenkins -> Manage Jenkins -> Configure System -> Global properties -> Environment variables I added:
Name: Path
Value: /bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
Reference
brew install ruby
brew install fastlane
Warning: fastlane 2.145.0 is already installed, it's just not linked
You can use brew link fastlane to link this version.
brew link fastlane
cd iOS
fastlane init
I have got the same issue on mac 10.11, after a lot of struggling I found that the problem in installing unf_ext 0.0.7.2 gem
I have done the following from this answer
brew install coreutils
After that try reinstall fastlane again it should work again
I faced this issue in Fedora 30 i followed these steps:-
1-installed all dev tools using these commands
sudo dnf install #development-tools
sudo dnf install #rpm-development-tools
2- run sudo gem install fastlane -NV
Fastlane worked like a charm
hope it helped
I managed to install following way
Install ruby
sudo apt install ruby ruby-dev
Add following to top of your "~/.profile" file
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Check of any errors with source ~/.profile command. If there is not output means all is good.
Install Build essentials
sudo apt-get update
sudo apt-get install build-essential
Fastlane depends on Google API Clint lets install that first
sudo gem install google-api-client
Install Fastlane
sudo gem install fastlane -NV
Check your installation
fastlane -v
Credits: This and this article helped me.
Flutter and Github Actions for Android:
If you are setting up Github Actions for a Flutter project for android and run into this error in one of your steps, see the work flow below:
jobs:
release:
runs-on: ubuntu-latest
env:
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
steps:
- uses: actions/checkout#v3
- name: Set up ruby
uses: ruby/setup-ruby#v1
- name: Setup Fastlane
working-directory: ./android # <-- Make sure you have this
run: bundle install
- name: Run Fastlane
working-directory: ./android. # <-- Make sure you have this
run: bundle exec fastlane android [lane name].
Make sure to setup the ruby/setup-ruby#v1 action correctly depending on your project. see the doc: https://github.com/ruby/setup-ruby
In my case I have not specified the ruby version because I am using the .ruby-version file in my project.
DO NOT INSTALL FASTLANE GLOBALLY
It is recommended that you use a Gemfile to define your dependency on Fastlane. This will clearly define the used Fastlane version, and its dependencies, and will also speed up using Fastlane.
Step 1: Install bundler using
sudo gem install bundler
so any time you wan run Fastlane
bundler exec fastlane ...
You can add fastlane path environment by add line
export PATH="$HOME/.fastlane/bin:$PATH"
to ~/.bash_profile or ~/.zsh_profile file (if you use zsh shell).
And final start new terminal session or reload using command source ~/.bash_profile or source ~/.zsh_profile (if you use zsh shell)
First,You need to check if you have the ~/.fastlane file. If you don't have the file, you can execute brew cask install fastlane command. If you already have it. Check other answers.
Get the full path of the fastlane executable from the command line:
which fastlane
Add it to the shell profile, restart shell.

Upgrade Node.js to the latest version on Mac OS

Currently I am using Node.js v0.6.16 on Mac OS X 10.7.4. Now I want to upgrade it to the latest Node.js v0.8.1. But after downloading and installing the latest package file from nodejs.org, I found that system is still using v0.6.16 instead of v0.8.1 when I typed "node -v" in a terminal. Is there any step that I have missed? Or, should I thoroughly uninstall the old version before installing the latest one?
BTW, I know that nvm can help to manage the nodejs package
https://github.com/creationix/nvm/
Is there any way to upgrade the Node.js without using it?
I have googled this problem, but it seems to me that there is no very clear answer to this question for the latest Node.js.
Here's how I successfully upgraded from v0.8.18 to v0.10.20 without any other requirements like brew etc, (type these commands in the terminal):
sudo npm cache clean -f (force) clear you npm cache
sudo npm install -g n install n (this might take a while)
sudo n stable upgrade to the current stable version
Note that sudo might prompt your password.
Additional note regarding step 3: stable can be exchanged for latest, lts (long term support) or any specific version number such as 0.10.20.
If the version number doesn't show up when typing node -v, you might have to reboot.
These instructions are found here as well: davidwalsh.name/upgrade-nodejs
More info about the n package found here: npmjs.com/package/n
More info about Node.js' release schedule: github.com/nodejs/Release
If you initially installed Node.js with Homebrew, run:
brew update
brew upgrade node
npm install -g npm
Or as a one-liner:
brew update && brew upgrade node && npm install -g npm
A convenient way to change versions is to use n:
brew install n
To install the latest version of Node.js with n:
n latest
Or, to install the latest LTS version with n:
n lts
Alternatively, you could use nvm instead of n:
brew install nvm
To install the latest version of Node.js with nvm:
nvm install node
If you installed via a package, then download the latest version from nodejs.org.
See Installing Node.js and updating npm.
Because this seems to be at the top of Google when searching for how to upgrade nodejs on mac I will offer my tip for anyone coming along in the future despite its age.
Upgrading via NPM
You can use the method described by #Mathias above or choose the following simpler method via the terminal.
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
After which you may opt to confirm the upgrade
node -v
Your nodejs should have upgraded to the latest version. If you wish to upgrade to a specific one say v0.8.19 then instead of
sudo n stable
use
sudo n 0.8.19
EDIT
Avoid using sudo unless you need to. Refer to comment by Steve in the comments
Go to http://nodejs.org and download and run the installer.
It works now - for me at least.
You could install nvm and have multiple versions of Node.js installed.
curl https://raw.github.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh
and then run:
nvm install 0.8.22 #(or whatever version of Node.js you want)
you can see what versions you have installed with :
nvm list
and you can change between versions with:
nvm use 0.8.22
The great thing about using NVM is that you can test different versions alongside one another. If different apps require different versions of Node.js, you can run them both.
I use Node version manager (called n) for it.
npm install -g n
then
n latest
OR
n stable
Simply go to node JS Website and install the latest version.
Do install latest version instead of the recommended stable version. It will give you freedom to use latest ES6 Features on node.
Can be Found here Node JS.
also to update npm, you will have to use this command.
sudo npm i -g npm#latest
All your projects will work fine.
Update: 2020 another good option is to use nvm for node which can then support multiple versions.
use nvm install --lts to always be able to update to latest node version use nvm ls-remote command to to check new versions of node.
Other option for mac :: brew update && brew install node && npm -g npm
Upgrade the version of node without installing any package, not even nvm itself:
sudo npx n stable
Explanations:
This approach is similar to Johan Dettmar's answer. The only difference is here the package n is not installed glabally in the local machine.
On macOS the homebrew recommended way is to run
brew install node
npm install -g npm#latest
I am able to upgrade the node using following command
nvm install node --reinstall-packages-from=node
There are five different ways (and counting?) to update Node.js on Mac:
Install the newer binary by downloading from nodejs.org
Update Node.js through Homebrew
Command: brew update && brew upgrade node
Update Node.js using Node Version Manager (NVM)
Command: nvm install {version} && nvm use {version}
Update Node.js using n package manager
Command: sudo n latest
Update Node.js through MacPorts
Command (same version update): sudo port selfupdate && sudo port upgrade {version}
If you are still using older MacOS version, it may be better to use lightweight, special-purpose package manager like n or nvm. You can refer to this sample use case for updating Node.js on old Mac (High Sierra).
Now this works for me:
sudo npm install -g n
sudo n latest
Happy code!
sadly, n doesn't worked for me. I use node version manager or nvm and it works like a charm. heres the link on how to install nvm: https://github.com/creationix/nvm#installation
nvm i 8.11.2 upgrade to latest LTS
nvm use 8.11.2 use it
node -v check your latest version
Go to the website nodejs.org and download the latest pkg then install.
it works for me
I used brew to upgrade my node. It has installed but it located in /usr/local/Cellar/node/5.5.0 and there is a default node in /usr/local/bin/node which bothers me. I don't want to make soft link because I don't really know how brew is organized.
So I download the pkg file, installed and I got this info:
Node.js was installed at
/usr/local/bin/node
npm was installed at
/usr/local/bin/npm
Make sure that /usr/local/bin is in your $PATH.
Now the upgrade is completed
Pretty Simple.
sudo npm i -g n
Then you can specify the version you want.
sudo n 12.8.0
Cheers!!
You can run but you can't hide... At the end you will be using NVM anyways.
You can just go to nodejs.org and download the newest package. It will update appropriately for you. NPM will be updated as well.
I think the simplest way to use the newest version of Node.js is to get the newest Node.js pkg file in the website https://nodejs.org/en/download/current/
if you want to use different version of Node.js you can use nvm or n to manage it.
sudo npm install -g n
and then
sudo n latest for linux/mac users
For Windows please reinstall node.
These 2 methods I tried are not working:
Use npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Manual install node from official website (https://nodejs.org/en/)
After trying, node -v still shows the old version of node.
Below method works for me:
Step 1: Install nvm (for more details: https://github.com/creationix/nvm#installation)
Open terminal and type this command:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
Close terminal and reopen it.
Type this command to check if nvm is installed:
command -v nvm
Step 2: To download, compile, and install the latest release of node, type this:
nvm install node ("node" is an alias for the latest version)
To check if node gets the latest version (v10.11.0).
Installing the latest node also installs the latest npm.
Check if npm gets the latest version (6.4.1).
Easy nad Safe Steps
Step 1: Install NVM
brew install nvm
Step 2: Create a directory for NVM
mkdir ~/.nvm/
Step 3: Configure your environmental variables
nano ~/.bash_profile
PASTE BELOW CODE
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
source ~/.bash_profile
Step 4: Double check your work
nvm ls
Step 5: Install Node
nvm install 9.x.x
Step6: Upgrade
nvm ls-remote
v10.16.2 (LTS: Dubnium)
v10.16.3 (Latest LTS: Dubnium) ..........
nvm install v10.16.3
Troubleshooting
Error Example #1
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
https://www.chrisjmendez.com/2018/02/07/install/
Nvm
Nvm is a script-based node version manager. You can install it easily with a curl and bash one-liner as described in the documentation. It's also available on Homebrew.
Assuming you have successfully installed nvm. The following will install the latest version of node.
nvm install node --reinstall-packages-from=node
The last option installs all global npm packages over to your new version. This way packages like mocha and node-inspector keep working.
N
N is an npm-based node version manager. You can install it by installing first some version of node and then running npm install -g n.
Assuming you have successfully installed n. The following will install the latest version of node.
sudo n latest
Homebrew
Homebrew is one of the two popular package managers for Mac. Assuming you have previously installed node with brew install node. You can get up-to-date with formulae and upgrade to the latest Node.js version with the following.
1 brew update
2 brew upgrade node
MacPorts
MacPorts is the another package manager for Mac. The following will update the local ports tree to get access to updated versions. Then it will install the latest version of Node.js. This works even if you have previous version of the package installed.
1 sudo port selfupdate
2 sudo port install nodejs-devel
for latest release:
nvm install node
specific version:
nvm install 6.14.4
https://github.com/creationix/nvm
Use nvm to upgrade node as per the project requirement..
install nvm through homebrew..
brew update
brew install nvm
mkdir ~/.nvm
nano ~/.bash_profile
In your .bash_profile file (you may be using an other file, according to your shell), add the following :
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
source ~/.bash_profile
echo $NVM_DIR
You can directly use curl to upgrade node to the latest version. Run the following command:
curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"
Reference: https://nodejs.org/en/download/package-manager/#macos
First install nvm with this command:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
credirts to #Saviah Kao
Then install node:
nvm install node --reinstall-packages-from=node
credits to #Elad
I had the same problem. This is what worked for me because I downloaded and installed node.js globally from the node.js website.
What I did was Give NVM (Node Version Manager) a try. Please do the commands in the following order in your terminal
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
command -v nvm
nvm install node
node -v (to confirm the update)
This is just to add some info for people who didn't have Node installed with Homebrew but getting that very error when trying to install packages with npm on Mac OS X.
I found this good article explaining how to completely remove Node whichever the way you originally installed it.
After node, npm and n were completely removed from my machine, I just reinstalled Node.js using the official .pckg installer from Node website and everything just went back to normal.
Hope this helps out someone.
An easy way is go straight to the website
https://nodejs.org/en/download/
Click download the latest version and install pkg file.
After that you will get the latest node and npm version
I'm using a Mac Mini M1. I just removed my very old packages of node.js and npm and decided to install them using homebrew. I found out that now brew install node also installs npm. FYI

How can I install Apache Ant on Mac OS X?

I tried to install Apache Ant on my Mac and I followed the next steps :
I downloaded apache-ant-1.8.1-bin.tar.gz into my Downloads folder.
I moved the file to /usr/local/ using this commands : sudo sh and mv apache-ant-1.8.1-bin.tar.gz /usr/local/
Now I want to use cd /usr/local/ but it's not working, I get back "No such file or directory".
Then I used cd /usr/ and ls commands and it seems that the local folder is there. If I try to access it I get the same error.
Since I already used sudo su why I can't access it? Any ideas?
Ant is already installed on some older versions of Mac OS X, so you should run ant -version to test if it is installed before attempting to install it.
If it is not already installed, then your best bet is to install Homebrew (brew install ant) or MacPorts (sudo port install apache-ant), and use those tools to install Apache Ant.
Alternatively, though I would highly advise using Homebrew or MacPorts instead, you can install Apache Ant manually. To do so, you would need to:
Decompress the .tar.gz file.
Optionally put it somewhere.
Put the "bin" subdirectory in your path.
The commands that you would need, assuming apache-ant-1.8.1-bin.tar.gz (replace 1.8.1 with the actual version) were still in your Downloads directory, would be the following (explanatory comments included):
cd ~/Downloads # Let's get into your downloads folder.
tar -xvzf apache-ant-1.8.1-bin.tar.gz # Extract the folder
sudo mkdir -p /usr/local # Ensure that /usr/local exists
sudo cp -rf apache-ant-1.8.1-bin /usr/local/apache-ant # Copy it into /usr/local
# Add the new version of Ant to current terminal session
export PATH=/usr/local/apache-ant/bin:"$PATH"
# Add the new version of Ant to future terminal sessions
echo 'export PATH=/usr/local/apache-ant/bin:"$PATH"' >> ~/.profile
# Verify new version of ant
ant -version
For MacOS Maveriks (10.9 and perhaps later versions too), Apache Ant does not come bundled with the operating system and so must be installed manually. You can use brew to easily install ant. Simply execute the following command in a terminal window to install brew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
It's a medium sized download which took me 10min to download and install. Just follow the process which involves installing various components. If you already have brew installed, make sure it's up to date by executing:
brew update
Once installed you can simply type:
brew install ant
Ant is now installed and available through the "ant" command in the terminal.
To test the installation, just type "ant -version" into a terminal window. You should get the following output:
Apache Ant(TM) version X.X.X compiled on MONTH DAY YEAR
Source: Error executing command 'ant' on Mac OS X 10.9 Mavericks when building for Android with PhoneGap/Cordova
If you are getting errors installing Brew, try uninstalling first using the command:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
Thanks to OrangeDog and other users for providing additional information.
If you have MacPorts installed (https://www.macports.org/), do this:
sudo port install apache-ant
If you're a homebrew user instead of macports, homebrew has an ant recipe.
brew install ant
To get Ant running on your Mac in 5 minutes, follow these steps.
Open up your terminal.
Perform these commands in order:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install ant
If you don't have Java installed yet, you will get the following error: "Error: An unsatisfied requirement failed this build."
Run this command next: brew cask install java to fix this.
The installation will resume.
Check your version of by running this command:
ant -version
And you're ready to go!
Use Brew is always good way to install ANT and other needs.
To install type below command on terminal.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
after Brew installation , type
brew install ant
This will install Ant on your system. Also you will not need to worry about setting up the path.
Also i have documented on the same - How to Install ANT on Mac OS?
The only way i could get my ant version updated on the mac from 1.8.2 to 1.9.1 was by following instructions here
http://wiki.eclipse.org/Ant/User_Guide
MacPorts will install ant for you in MacOSX 10.9. Just use
$ sudo port install apache-ant
and it will install.

Resources