After days trying install casperjs on my Mac, i'm asking some help. I first used "brew install" method and NPM, this is terminal's messages :
brew install casperjs
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles-portable-ruby/portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring portable-ruby-2.6.3_2.yosemite.bottle.tar.gz
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> New Formulae
[...]
==> Updated Formulae
Updated 4842 formulae.
==> Renamed Formulae
[...]
==> Deleted Formulae
[...]
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
==> Tapping homebrew/cask
[...]
==> Searching for similarly named formulae...
Error: No similarly named formulae found.
Error: No available formula or cask with the name "casperjs".
==> Searching for a previously deleted formula (in the last month)...
Warning: homebrew/core is shallow clone. To get its complete history, run:
git -C "$(brew --repo homebrew/core)" fetch --unshallow
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.
So I tried installing with NPM
npm install casperjs -g
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
Thank you in advance,
An edit three years later: if anyone comes across this, I really like mise
right now! It's a polyglot version manager, so it works for basically every language, and I switched to it after using asdf
for a while. Here's the website.
tl;dr: you should probably try a version manager like nodenv
You're right, brew.sh doesn't list any casper.js
formulae; I'm not sure why Casper lists it as an installation option in their docs. You could indeed install it using npm and sudo
, but a better way to get started is to use a version/environment manager, like nodenv: it allows easy switching of Node.js versions globally, per-project based on a node-version
file, or per-shell with an environment variable. Perhaps more importantly, since it installs node modules into a version-specific folder within ~/.nodenv
(where ~/
refers to your user/home folder), it doesn't require sudo
, which is safer and just generally better practice. You can install nodenv
with Homebrew, too, which is nice. There are also other version managers, like NVM
and n
— I tried them both, but I found nvm
to slow down shell startup far too much, and n
doesn't allow per-project switching, and on top of all of that I just like the way nodenv
works. For a different approach to version management, there's asdf
, which is a language-agnostic version manager (though I haven't tried it). Any of them should solve the issue, though.
Also, I'm not sure if you installed Node with Homebrew with the intent of using it for development, but if so, that's probably not the greatest idea either — lots of other Homebrew formulae depend on Node, and when you run brew upgrade
to update your packages, there's always a possibility that you wind up unwittingly upgrading Node as a dependency of another formula, which would likely break something you've done or some npm module(s). Basically, it's the same general concept as this blog post about why not to use Homebrew's Python, but with Node.
Hopefully that's helpful!