我在Yosemite上,安装了Homebrew,Node和NPM。
Homebrew 0.9.5 节点v0.12.3 NPM 2.9.1
无论出于何种原因,我无法让Yeoman正确安装。安装似乎没问题,没有错误,但是当我检查确认安装时它不会给我--version,也不能执行你的yo功能......
Gregs-MacBook-Pro:~ G$ npm install -g yo
/Users/G/npm/bin/yo -> /Users/G/npm/lib/node_modules/yo/lib/cli.js
> yo@1.4.6 postinstall /Users/G/npm/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ NODE_PATH matches the npm root
Everything looks all right!
yo@1.4.6 /Users/G/npm/lib/node_modules/yo
├── titleize@1.0.0
├── array-uniq@1.0.2
├── figures@1.3.5
├── user-home@1.1.1
├── opn@1.0.2
├── async@0.9.2
├── humanize-string@1.0.1 (decamelize@1.0.0)
├── sort-on@1.2.0 (dot-prop@2.0.0)
├── yeoman-character@1.0.1 (supports-color@1.3.1)
├── string-length@1.0.0 (strip-ansi@2.0.1)
├── cross-spawn@0.2.9 (lru-cache@2.6.4)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
├── yosay@1.0.4 (ansi-regex@1.1.1, ansi-styles@2.0.1, word-wrap@1.0.3, strip-ansi@2.0.1, pad-component@0.0.1, taketalk@1.0.0, minimist@1.1.1)
├── root-check@1.0.0 (sudo-block@1.2.0, downgrade-root@1.1.0)
├── update-notifier@0.3.2 (is-npm@1.0.0, latest-version@1.0.0, semver-diff@2.0.0)
├── package-json@1.1.0 (registry-url@3.0.3)
├── npm-keyword@1.1.1 (registry-url@3.0.3)
├── meow@3.1.0 (object-assign@2.0.0, minimist@1.1.1, camelcase-keys@1.0.0, indent-string@1.2.1)
├── got@2.9.2 (lowercase-keys@1.0.0, object-assign@2.0.0, timed-out@2.0.0, is-stream@1.0.1, prepend-http@1.0.1, nested-error-stacks@1.0.0, statuses@1.2.1, infinity-agent@2.0.3, read-all-stream@2.1.2, duplexify@3.4.0)
├── fullname@1.1.0 (npmconf@2.1.2)
├── yeoman-environment@1.2.5 (escape-string-regexp@1.0.3, log-symbols@1.0.2, untildify@2.0.0, diff@1.4.0, text-table@0.2.0, debug@2.2.0, mem-fs@1.1.0, grouped-queue@0.3.0, globby@1.2.0)
├── configstore@0.3.2 (object-assign@2.0.0, xdg-basedir@1.0.1, osenv@0.1.1, graceful-fs@3.0.7, uuid@2.0.1, mkdirp@0.5.1, js-yaml@3.3.1)
├── lodash@3.9.2
├── insight@0.5.3 (object-assign@2.0.0, lodash.debounce@3.1.0, os-name@1.0.3, tough-cookie@0.12.1, request@2.55.0)
├── yeoman-doctor@1.3.2 (object-values@1.0.0, log-symbols@1.0.2, each-async@1.1.1, twig@0.7.2)
└── inquirer@0.8.5 (ansi-regex@1.1.1, cli-width@1.0.1, through@2.3.7, readline2@0.1.1, rx@2.5.2)
Gregs-MacBook-Pro:~ G$ yo -v
-bash: yo: command not found
我已经打开了.bashrc(必须使用sudo才能打开+保存它)。没有sudo,我无法保存更改。
sudo nano /.bashrc
bashrc文件显示为:
# NPM packages in homedir
NPM_PACKAGES="$HOME/.npm-packages"
# Tell our environment about user-installed node tools
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
# Tell Node about these packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
我已经尝试首先通过Homebrew安装Node,然后发现了我无法解决的问题。 https://gist.github.com/DanHerbert/9520689
因为那不是我在终端中吹走所有东西,包括node,npm和homebrew。
现在我被卡住了,npm让我安装了grunt-cli,bower和yeoman的软件包,但是每当我尝试调用那些软件包时我都会:
-bash: yo: command not found
我假设它与/.bashrc内容有关,有人帮忙:(
答案 0 :(得分:0)
我在优胜美地下遇到了同样的问题。
我的解决方案是:
sudo find /usr/local/ -name yo
/usr/local//Cellar/node/4.2.1/libexec/npm/bin/yo
打开$ HOME / .profile
export NODE_PATH="/usr/local/lib/node_modules"
export PATH="/usr/local/Cellar/node/4.2.1/libexec/npm/bin:$PATH"
export NODE_PATH=$NODE_PATH:/usr/local/Cellar/node/4.2.1/libexec/npm/lib/node_modules
打开新终端:
yo --version
1.4.8
也许你的节点版本是个问题。在安装'brew install node'之后开始我也是
node --version
v0.12.7
之后
brew update
并重新安装节点
node --version
v4.2.1