to npm module

19 views
Skip to first unread message

Michael Bykov

unread,
Oct 31, 2013, 12:18:52 PM10/31/13
to compo...@googlegroups.com
Hello,

How can I convert my component to node module?

Thank you!

vision media [ Tj Holowaychuk ]

unread,
Oct 31, 2013, 2:35:05 PM10/31/13
to compo...@googlegroups.com
depends, you can just add a package.json but other than pure javascript components they are incompatible


--
You received this message because you are subscribed to the Google Groups "component" group.
To unsubscribe from this group and stop receiving emails from it, send an email to componentjs...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ericgj

unread,
Oct 31, 2013, 2:56:50 PM10/31/13
to compo...@googlegroups.com
One useful component for this is ForbesLindesay/is-browser .  Then you can do "conditional requires" depending on if you are in browser or node land.

var isBrowser = require('is-browser');
var thing = isBrowser ? require('some-component')  : require('some-equivalent-npm-module')

Usually more complicated than this but if it's pure javascript that's the way I'd do it.

Ian Storm Taylor

unread,
Oct 31, 2013, 2:59:06 PM10/31/13
to compo...@googlegroups.com
personally unless i can get the same npm module name i just prefer not to publish to npm and then reference it using the github syntax:

"name": "user/name"

that way you don't have to mess with try/catch or is-browser stuff
--

ericgj

unread,
Oct 31, 2013, 3:06:33 PM10/31/13
to compo...@googlegroups.com
Yeah that's fine for your own component, but dependencies you're stuck with the npm name... even if you reference them using github syntax.

vision media [ Tj Holowaychuk ]

unread,
Oct 31, 2013, 3:14:29 PM10/31/13
to compo...@googlegroups.com
yeah I found that weird, it's like the name you specify as the key is irrelevant if you use user/repo with npm, pretty weird
Reply all
Reply to author
Forward
0 new messages