node.js 有虚拟环境吗? [英] Is there a virtual environment for node.js?

查看:68
本文介绍了node.js 有虚拟环境吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了 wiki 模块页面,但找不到任何类似于 virtualenv (python) 或 rvm 的内容.

I've searched the wiki modules page, but I can't find anything similar to virtualenv (python) or rvm.

这里有人在他们自己的环境中分离 node.js 吗?我真的不喜欢在系统范围内安装 npm.

Anyone here separates node.js in their own env? I really don't like to install npm system-wide.

推荐答案

如果拥有系统范围的 npm 包是您的主要问题,那么也许可以考虑将非常酷的bundle"命令与 npm 结合使用.这更接近于冻结 gem 或在 rails 中使用 bundler,而不是 rvm.

If having system wide npm packages is your main issue, then maybe consider using the very cool 'bundle' command with npm. This is closer to freezing gems or using bundler in rails, rather than rvm.

超级简单.只需创建一个 package.json 文件:

It's super easy. Just create a package.json file:

{ "name": "yourapp", "version": "0.0.1", "dependencies": {"jade": "0.4.1"}}

然后运行:

npm bundle vendor

或者如果您的 npm 版本 >= 1.0 运行:

or if your npm version is >= 1.0 run:

npm install

冻结到供应商目录中.然后使用:

to freeze into the vendor directory. and then use:

require.paths.unshift('./vendor');

这篇关于node.js 有虚拟环境吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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