brew 里的 node.js 安装的时候不创建 npm 的符号链接?

2014-05-07 16:51:09 +08:00
 Livid
brew link node 然后执行 npm 还是 command not found?
11474 次点击
所在节点    Node.js
21 条回复
wtl
2014-05-07 17:02:38 +08:00
也碰到这个问题 后来就直接下安装包了
dorentus
2014-05-07 17:07:21 +08:00
我的是有的

莫非你是带 --without-npm 参数安装的?
Livid
2014-05-07 17:07:48 +08:00
@dorentus 就用 brew install node 装的。

刚刚也直接去下载官网安装包了。
zieglar
2014-05-07 17:08:13 +08:00
还是用 nvm 来处理比较好
fundon
2014-05-07 17:08:36 +08:00
`brew edit node` 默认加了 `--without-npm`

执行 `brew install node --with-npm`
fundon
2014-05-07 17:09:17 +08:00
推荐nvm,切换版本方便
ohsc
2014-05-07 17:10:55 +08:00
单独安装吧,npm本身可以自我升级,再纳入brew管理会有问题。

https://github.com/Homebrew/homebrew/pull/27479
dorentus
2014-05-07 17:13:05 +08:00
@fundon 难怪。。他们为啥要这么做。。

不过更奇怪的是我直接装还是带 npm 的:

Livid
2014-05-07 17:13:54 +08:00
@dorentus 你的 brew 已经有一段时间没更新了。
ohsc
2014-05-07 17:17:47 +08:00
如果你已经安装了npm,更新node后brew会执行 /usr/local/bin/npm update npm -g
dorentus
2014-05-07 17:23:42 +08:00
@Livid 嗯,确实是这个原因。

不过其实就是晚了一天没更新。

原因是这个 commit: https://github.com/Homebrew/homebrew/commit/15846a5d131f69ec8e9ddc263f1cabfa63b0c2f4#diff-ba7ac8bf3cbc78ff35d6909b6074ee5e

我觉得大概是这样:
虽然 formula 里面很早就默认加了 --without-npm,但是平常大家不带参数装的时候,其实是直接下载的预先打包好的 tarball(bottled do ... end 那里),然后这个 commit 之前的 0.10.26 版的 tarball,估计还是带了 bin/npm 的,但是 0.10.28 里面它被删掉了……
chrisyipw
2014-05-07 17:28:48 +08:00
似乎和版本有关的,brew install node 一直都会安装 npm,但安装 dev 时则不会安装。

鉴于 brew 安装的 npm 之前有过不少问题,比如 npm update -g 无法更新 npm 自身 (报错) ,可能独立安装 npm 会更保险。

至于 nvm,这家伙目前并没有设置全局的功能,我是 brew 安装一个稳定版作为全局使用,用 nvm 控制不同版本的切换。
fundon
2014-05-07 17:36:23 +08:00
还有另外一个选择,使用boxen管理环境,装https://github.com/boxen/puppet-nodejs

默认带了 nodenv 命令,比nvm方便

```
λ ~ nodenv help (node-v0.10.26) 17:32:59
Usage: nodenv <command> [<args>]

Some useful nodenv commands are:
exec Execute a command from a particular NodeJS version.
shell Set NODENV_VERSION for the lifetime of a shell.
local Persist the preferred NodeJS version in the cwd.
global Persist the preferred NodeJS default version.
install Install a version of NodeJS.
uninstall Uninstall a version of NodeJS.
version Show the current NodeJS version.
versions Display all versions of NodeJS installed in `${NODENV_ROOT}/versions/*'.
rehash Rehash nodenv shims (run this after installing executables)

See `nodenv help <command>' for information on a specific command.
```
mahone3297
2014-05-07 20:00:53 +08:00
port安装。。。
sd4399340
2014-05-07 22:10:55 +08:00
试试 brew postinstall node

我刚才更新node的时候brew报这个错

npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/pinky/npm-debug.log
npm ERR! not ok code 0
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`

不过我也没注意运行这个之前npm正常不,反正运行后是正常的
newtonisaac
2014-05-09 01:25:02 +08:00
.npm目录及子目录权限改为可读可写
sdhjl2000
2014-05-27 17:53:39 +08:00
刚遇到这个问题,根据提示发现是权限问题:sudo brew postinstall node
Feiox
2014-08-07 10:47:16 +08:00
@sd4399340 我遇到了同样的报错信息,是在 brew install node 时就遇到的。您是怎么解决的呢
sd4399340
2014-08-09 17:03:30 +08:00
@Feiox 我好像最后就是用 brew postinstall node
cz5424
2020-01-05 11:19:03 +08:00
brew install node 发现没有 npm
带有提示 brew postinstall node 失败
brew postinstall node --debug
看到 npm 目录报没有权限 => /usr/local/lib/node_modules/npm
chown 授权
brew postinstall node 成功

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/111508

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX