is there an virtual environment for node.js?

2019-01-29 18:19发布

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

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

8条回答
Summer. ? 凉城
2楼-- · 2019-01-29 18:48

If you like it simple, I truely recommend visionmedia's n, could not be easier!

https://github.com/visionmedia/n

查看更多
贪生不怕死
3楼-- · 2019-01-29 18:49

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.

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

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

and then run:

npm bundle vendor

or if your npm version is >= 1.0 run:

npm install

to freeze into the vendor directory. and then use:

require.paths.unshift('./vendor');
查看更多
登录 后发表回答