Re: Proposed F19 Feature: NodeJS - The JavaScript runtime and associated ecosystem, including the npm package manager

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 1/9/13, Matej Cepl <mcepl@xxxxxxxxxx> wrote:
> On 08/01/13 20:49, T.C. Hollingsworth wrote:
>> Not much different than e.g. Python's easy_install/pip and RPM.  You
>> can install packages using both RPM/yum and npm, and `npm install -g`
>> can possibly get you into trouble just like `easy_install` outside a
>> virtualenv can.
>
> With pip (run as normal user) I can install in
> $HOME/.local/lib/python*/site-packages/ so that the system-wide
> installed packages are not touched, but all projects created by user can
> use them. Can I do something like that with npm?

Yes and no.  I think there's a bit of confusion on how the node module
loader actually works, so I'll provide a concrete example.

Say your working on the Next Big WebApp, in ~/nbw/, and you want to
use the express web framework, which we don't have packaged in Fedora
yet, and the async library, which we do.  You would just `cd ~/nbw/`,
`npm install express` to install express from the npm registry (and
also install express' dependencies into
~/abw/node_modules/express/node_modules, and so on recursively) into
~/nbw/node_modules/express, and then `npm link async` to effectively
`ln -sf /usr/lib/node_modules/async ./node_modules/async`.  You can
then create an e.g. 'app.js' file and require('express') and 'async'
to your hearts content.  However, you can't require('inherits'), even
though /usr/lib/node_modules/inherits exists, because node has no
notion of a global module loading path.  Everything must be explicitly
provided in ~/abw/node_modules, whether its an actual module tree or a
symlink to one somewhere else on the system.

So you probably wouldn't want to create a '~/.local/lib/node_modules'
directory., though you could `export
NODE_PATH=/usr/lib/node_modules:~/.local/lib/node_modules' if that's
*really* what you want.

The motivation behind this is explained somewhat in the npm FAQ:
https://npmjs.org/doc/faq.html#I-installed-something-globally-but-I-can-t-require-it

-T.C.
-- 
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/devel



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux