[nodejs]how to add /usr/local/node_modules to node paths

1,352 views
Skip to first unread message

jason.桂林

unread,
Nov 1, 2011, 4:37:32 AM11/1/11
to nod...@googlegroups.com
Hi folks,

I just install npm 1.0.95 and node 0.4.12 on mac os X lion, but when I do `npm install something -g` it does not works, but I do `npm install something` at HOME, it works, so I check require.paths, it is 


[ '/Users/username/.node_modules', '/Users/username/.node_libraries', '/usr/local/lib/node' ]

No /usr/local/lib/node_modules in there.

Before this, I installed node 0.5 first, and I unintsall it, and reinstall node 0.4, what's wrong? 

-- 
Best regards,

Jason Green
桂林


Dominic Tarr

unread,
Nov 1, 2011, 5:48:38 AM11/1/11
to nod...@googlegroups.com
require.paths is removed in 0.5, that may have something to do with it.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Isaac Schlueter

unread,
Nov 1, 2011, 11:10:28 AM11/1/11
to nod...@googlegroups.com
Use local installs if you want to require() a module. This is covered
in remarkable detail in the npm documentation. Run the `npm faq`
command, and read it. Use the link command to link global modules
into your local space. Read about it in `npm help link`.

Use node 0.5. If you are just starting out, the 0.4 is not for you.
It will be deprecated very soon. Use 0.5.10, and upgrade to 0.6 as
soon as it is available.

Don't look at require.paths. Look at require("module").globalPaths.
Note that this is merely a copy; changing it will have no effect.

Give local package installation a try. A lot of experienced noders
really like it. You might find it to be a useful way to organize your
projects as well.

--

If you are still not convinced that local package installation/linking
is better, you can do this add this to your environment:

NODE_PATH=/usr/local/lib/node_modules

jason.桂林

unread,
Nov 7, 2011, 8:53:43 AM11/7/11
to nod...@googlegroups.com
require('module').globalPaths: 

   [ '/Users/username/.node_modules',
     '/Users/username/.node_libraries',
     '/usr/local/lib/node' ],

How could I add /usr/local/lib/node_module to this PATH?

Mark Hahn

unread,
Nov 7, 2011, 4:39:35 PM11/7/11
to nod...@googlegroups.com
How could I add /usr/local/lib/node_module to this PATH?

Put a symlink to that in your app's directory.  I think npm does this automatically but I don't know the command.

Reply all
Reply to author
Forward
0 new messages