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,
tl;dr: you should probably try a version manager like
nodenvYou're right, brew.sh doesn't list any
casper.jsformulae; I'm not sure why Casper lists it as an installation option in their docs. You could indeed install it using npm andsudo, 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 anode-versionfile, 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 requiresudo, which is safer and just generally better practice. You can installnodenvwith Homebrew, too, which is nice. There are also other version managers, likeNVMandn— I tried them both, but I foundnvmto slow down shell startup far too much, andndoesn't allow per-project switching, and on top of all of that I just like the waynodenvworks. For a different approach to version management, there'sasdf, 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 upgradeto 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!