在 Mac 上安装 casperjs 有困难
Difficulties installing casperjs on Mac
在我的 Mac 上尝试安装 casperjs 几天后,我正在寻求帮助。
我首先使用“brew install”方法和 NPM,这是终端的消息:
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.
所以我尝试使用 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
提前谢谢你,
尝试使用 sudo 访问权限。然后错误消息说,您无权将 npm-packages 写入文件夹 note-modules.
使用 sudo
,您可以暂时成为 root 访问权限,以安装、删除或更改任何软件。
sudo npm i casperjs -g
tl;dr:您可能应该尝试像 nodenv
这样的版本管理器
你是对的,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
,它是一个与语言无关的版本管理器(尽管我还没有尝试过)。不过,他们中的任何一个都应该可以解决问题。
此外,我不确定您安装 Node 和 Homebrew 是否是为了将其用于开发,但如果是这样,那可能也不是最好的主意 — 许多其他 Homebrew 公式都依赖于 Node,以及何时你 运行 brew upgrade
来更新你的包,你总是有可能无意中将 Node 升级为另一个公式的依赖项,这可能会破坏你所做的事情或一些 npm 模块.基本上,它与 this blog post about why not to use Homebrew's Python 的一般概念相同,但带有 Node.
希望对您有所帮助!
在我的 Mac 上尝试安装 casperjs 几天后,我正在寻求帮助。 我首先使用“brew install”方法和 NPM,这是终端的消息:
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.
所以我尝试使用 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
提前谢谢你,
尝试使用 sudo 访问权限。然后错误消息说,您无权将 npm-packages 写入文件夹 note-modules.
使用 sudo
,您可以暂时成为 root 访问权限,以安装、删除或更改任何软件。
sudo npm i casperjs -g
tl;dr:您可能应该尝试像 nodenv
你是对的,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
,它是一个与语言无关的版本管理器(尽管我还没有尝试过)。不过,他们中的任何一个都应该可以解决问题。
此外,我不确定您安装 Node 和 Homebrew 是否是为了将其用于开发,但如果是这样,那可能也不是最好的主意 — 许多其他 Homebrew 公式都依赖于 Node,以及何时你 运行 brew upgrade
来更新你的包,你总是有可能无意中将 Node 升级为另一个公式的依赖项,这可能会破坏你所做的事情或一些 npm 模块.基本上,它与 this blog post about why not to use Homebrew's Python 的一般概念相同,但带有 Node.
希望对您有所帮助!