【发布时间】:2015-05-25 03:13:41
【问题描述】:
我在 Yosemite 上,安装了 Homebrew、Node 和 NPM。
自制 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
因为我没有把终端中的所有东西都吹走,包括节点、npm 和自制软件。
现在我被卡住了,npm 让我安装包 grunt-cli、bower 和 yeoman,但任何时候我尝试调用这些包时都会得到:
-bash: yo: command not found
我假设它与 /.bashrc 内容有关,有人帮忙:(
【问题讨论】:
-
在
OS X中,您应该将导出内容放入~/.bash_profile,然后退出并重新启动Terminal。 -
尝试将此添加到 ~/.bash_profile 并重新启动。
echo export PATH=\"\$PATH\":~/.node/bin >> ~/.bash_profile运气不好:/ -
在终端尝试命令
which yo或which yeoman,有什么出现吗? -
两者都没有。
-
如果你做
ls /usr/local/share/npm/bin/ | grep yo,它输出“yo”然后尝试创建一个符号链接ln -s /sbin/ /usr/local/share/npm/bin/yo
标签: npm homebrew yeoman osx-yosemite