尽管 Mac 上的 NODE_PATH 正确,但无法使用 NPM 安装的节点模块 [英] Can't use node modules installed by NPM despite correct NODE_PATH on a Mac

查看:47
本文介绍了尽管 Mac 上的 NODE_PATH 正确,但无法使用 NPM 安装的节点模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 OSX 10.7 (Lion) 上运行.尝试在此处包含尽可能多的细节.我(愚蠢地?)决定升级到最新的 NODE 和 NPM.我像一个好孩子一样 git-ed 和 curl-ed,结果是这样的:

Running on OSX 10.7 (Lion). Tried including as much detail here. I (foolishly?) decided to upgrade to the latest NODE and NPM. I git-ed and curl-ed like a good boy, and ended up with this:

>node -v
v0.5.9
>npm -v
1.0.99

添加了 export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node 产生:

>echo $NODE_PATH
/usr/local/lib/node_modules:/usr/local/lib/node

但是我所有脚本中的每个 require 都无法找到我的任何模块.它要么在本地库中查找,要么只是放弃错误:找不到模块"消息.

But every require I have in all my scripts fails in finding any of my modules. It either looks in the local library, or just gives up with an "Error: Cannot find module" message.

我尝试了 NODE_PATH 的变体:有/没有 node_modules,有特定的目录 - nada.

I tried variations on the NODE_PATH: with/without the node_modules, with specific directories - nada.

我是否缺少一些 NPM 配置?我使用它不正确吗?所有脚本在升级前都运行良好.

Am I missing some NPM configuration? Am I using it incorrectly? All the scripts worked well prior to the upgrade.

感谢您的帮助.

推荐答案

最终通过将模块本地安装到特定节点目录中解决.

Finally solved it by installing modules locally into the specific node directories.

这篇关于尽管 Mac 上的 NODE_PATH 正确,但无法使用 NPM 安装的节点模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆