Node.js - 使用NVM配置$ NODE_PATH [英] Node.js - Configuring $NODE_PATH with NVM

查看:340
本文介绍了Node.js - 使用NVM配置$ NODE_PATH的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 NVM 设置 Node.js 的路上,我在使用<$ c时偶然发现错误$ C>约曼。我得到
错误

On my way setting up Node.js with NVM, I stumbled upon an error when using Yeoman. I got the error

Cannot find module 'yeoman-generator'

经过一番研究后我发现 StackOverflow上的这篇文章,这也是我的问题。现在我尝试这样做了,但我遇到的问题是,我想在系统中使用不同版本的Node.js并使用NVM。如果Node.js版本在NVM的帮助下发生变化,现在可以动态更改$ NODE_PATH吗?因为我的$ NODE_PATH目前是空的(这导致问题)。

After some research I found this post on StackOverflow, which is also about my problem. Now I tried to do so, but the problem I have is, that I want to use different versions of Node.js over the system with the use of NVM. Now is it possible to change the $NODE_PATH dynamically, if the Node.js version changes with the help of NVM? Because my $NODE_PATH is empty at the moment (this is causing the problem).

$ which node
/Users/dschmidt/.nvm/v0.10.35/bin/node
$ which npm
/Users/dschmidt/.nvm/v0.10.35/bin/npm
$ echo $NODE_PATH
[empty]

对于我得到的每一个答案都会很高兴。我在网上搜索了这个,但找不到一篇关于此的帖子。

Would be glad about every answer I get about this. I searched the web for this, but could not find one post about this specifically.

推荐答案

添加以下内容 .bashrc .zshrc 帮助

export NODE_PATH=$NODE_PATH:`npm root -g`

我不是专家,这是不是很好。

I am not expert whether that is good.

来源 Pensierinmusica指出

source as pointed out by Pensierinmusica

这篇关于Node.js - 使用NVM配置$ NODE_PATH的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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