Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

> A specially named directory, node_modules/, is searched in the current directory for any modules.

Awesome. Currently NPM expects unprivileged users to have access to /usr/local, and a lot of node tutorials encourage global repermissioning of this directory, which is Bad Unix.

Hopefully, once NPM gets updated, you'll have a Python virtualenv/Ruby equivalent style project-specific install system.

Update: https://github.com/isaacs/nave says Nave provides virtualenvs for Node, which may be worth checking out.



npm currently supports ~/.node_modules, by the way (which node has supported for ages)


But then you are still relying on modules available and their versions on the system where the node app is running. Bundling is a much more reliable way of doing things.


Bundling (and the like) is a necessary evil of ecosystems riding hard on the bleeding edge, like node.js...

... and I would say Ruby/Rails, but they ought to be growing up by now, and integrating sensibly with platform package management. :-)

The difference between Python and Ruby on Debian/Ubuntu systems is astounding, and as the node.js ecosystem matures I dearly hope it will look more like the Python world than the unending adolescence of Ruby/Rails.


I don't think it's really fair to lay all of the blame with node and ruby/rails in this case; the distro package managers are just as much at fault:

http://sheddingbikes.com/posts/1285063820.html

It really just depends on what you're trying to do. As a desktop user you probably care most about stability; we can't have a python upgrade breaking apt. As a developer it's often important to have an up-to-date version of the tools and libraries you're using.


> the unending adolescence

It has nothing to do with adolescence, and everything to do with different priorities. Debian favors stability, Ruby favors breakneck progress. Each has their pros and cons.


Awesome! Alas the doc I've been reading all points to the normal /usr/local method (eg, https://github.com/isaacs/npm/blob/master/doc/faq.md doesn't mention the new stuff). How can I make it use ~/.node_modules?


In your ~/.npmrc:

root = ~/.node_libraries


Thanks!


> Currently NPM expects unprivileged users to have access to /usr/local, and a lot of node tutorials encourage global repermissioning of this directory, which is Bad Unix

NPM reminds you do "sudon't" if you run it as root.

Configuring it to use ~/.node_modules is not very straight forward or obvious but once you do it everything would work with an unprivileged user and without messing up Unix.


> NPM reminds you do "sudon't" if you run it as root.

To install NPM itself, you either get a bunch of 'sudont' errors or have the app fail with the normal, secure /usr/local permissions when it can't write there.

Try it.


I ran into this a few days ago. I ended up reinstalling node with a prefix of ~/local, and then when I built npm it automatically used the same prefix.


can one do a chroot?




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: