全局节点模块安装不正确.没有找到指令 [英] Global Node modules not installing correctly. Command not found

查看:26
本文介绍了全局节点模块安装不正确.没有找到指令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在安装全局节点模块时遇到问题,我在网上找到的所有内容都说解决方案只是添加 -g.这不是问题.我相信这是一个链接问题或错误的目录问题.

I am having a problem installing global node modules and everything I find online says the solve is just adding -g. Which is not the problem. I believe it's a linking issue or wrong directory issue.

这是我所做的:

$ npm install -g express
npm http GET https://registry.npmjs.org/express
npm http 304 https://registry.npmjs.org/express
npm http GET https://registry.npmjs.org/range-parser/0.0.4
npm http GET https://registry.npmjs.org/mkdirp/0.3.3
...downloads correctly

$ express myapp
bash: express: command not found

但是,当我运行直接链接位置来表达它时:

However when I run the direct link location to express it works:

   $ /usr/local/share/npm/bin/express myapp

   create : myapp
   create : myapp/package.json
   create : myapp/app.js
... Builds app correctly

模块在哪里:

$ which node
/usr/local/bin/node
$ node -pe process.execPath
/usr/local/Cellar/node/0.8.20/bin/node
$ npm link express
/Users/bentonrr/Development/Personal/node_modules/express -> /usr/local/share/npm/lib/node_modules/express

在我的 .bash_profile 我有:

In my .bash_profile I have:

export PATH=/usr/local/bin:$PATH
export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node

我是否需要更改我的 Node 环境才能下载到正确的文件夹?是不是链接不正确?我迷路了..

Do I need to change my Node environment to download to correct folder? Is something not linking correctly? I am lost..

谢谢!

其他规格:

$ node --version
v0.8.20
$ npm --version
1.2.11
$ brew --version
0.9.4
OSX Version 10.8.2

推荐答案

$(npm get prefix)/bin 添加到您的 PATH(例如,在 .bashrc),像这样:

Add $(npm get prefix)/bin to your PATH (e.g., in .bashrc), like so:

echo "export PATH=$PATH:$(npm get prefix)/bin";>>~/.bashrc

更多信息,请参见npm help npm:

全局模式:npm 将包安装到 prefix/lib/node_modules 的安装前缀中,bins 安装在 prefix/bin 中.

global mode: npm installs packages into the install prefix at prefix/lib/node_modules and bins are installed in prefix/bin.

您可以使用 npm get prefixnpm config list | 找到安装前缀 |grep 前缀.

这篇关于全局节点模块安装不正确.没有找到指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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