News for hackers. Stuff that matters.
Re:Show HN: CLI for trying out Node.js modules easier by gravypod on Monday March 14, 2016 @02:44AM (#11281395)
This is one of those really cool ideas that is obvious after someone else much smarter then yourself thinks of it first.

I wish this was in NPM.

Re:Show HN: CLI for trying out Node.js modules easier by tolmasky on Monday March 14, 2016 @05:10AM (#11281754)
Actually it is, at least the npm website. Every page on npm has a "try it now" link that takes you to a page on tonicdev where you can try the package. For example: http://tonicdev.com/npm/canvas - no need to download, build, or install. It loads a container so you have a real node environment (I'm a dev in this if you have any questions).
Re:Show HN: CLI for trying out Node.js modules easier by BillinghamJ on Monday March 14, 2016 @12:06PM (#11283620)
I use this regularly - it's great. Only issue is I can never remember the domain name! :)

It'd actually be pretty helpful if you made it something like https://try.tonicdev.com/npm/canvas because then I can just type "try." and my browser will find it for me.

Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @08:55AM (#11282551)
Glad to see you here, I love tonicdev and use it when I can! Too bad I can't try out CLI/Terminal specific stuff in it, at least what I found so far...

However, one question, you guys have any plans for an offline version?

Re:Show HN: CLI for trying out Node.js modules easier by Touche on Monday March 14, 2016 @09:44AM (#11282829)
I want NPM to do less, not more. Start by fixing the cli, make it far less noisy than it is; think about whether you need to dump a project's entire dependency tree (which might consume my terminal's entire scrollable space -- a big no-no). Think about whether you should allow a module 6 levels deep that depends on a deprecated version of babel display warnings about that; is that relevant to my project? Oh, and group warnings together, don't dump them as you find them.

This is all just off the top of my head. Making it faster would be good too, shouldn't take 15 minutes to install a project's dependencies; pnpm and others are proving this is fixable.

Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @02:46AM (#11281398)
Absolutely! And I'm no way the first person who did this, my inspiration comes from diving into clojure and finding `lein-try` (https://github.com/rkneufeld/lein-try).

Thanks for your kind words though.

Re:Show HN: CLI for trying out Node.js modules easier by nilved on Monday March 14, 2016 @10:16AM (#11282994)
This isn't a new idea. I enjoyed using a Clojure equivalent for a while[0], and this post inspired me to create a Haskell version[1].

[0]: https://github.com/rkneufeld/lein-try [1]: https://github.com/devlinzed/cabal-try

Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @10:18AM (#11283009)
As replied below, the inspiration of trymodule is coming from lein-try :)

And awesome to see I could inspire cabal-try to be conceived! (even though I do zero Haskell)

Re:Show HN: CLI for trying out Node.js modules easier by murukesh_s on Monday March 14, 2016 @10:05AM (#11282936)
Just 57 lines of code. Someone was asking about beautiful code in other thread, I believe this is a fine example of it. Plumbing together reusable modules to build useful (and never before imagined) stuff. Kudos to the author and the node.js ecosystem..
Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @10:11AM (#11282965)
Yeah, saw that though but can't agree that this would be an example of it. It's more an example of the later part, the beauty of having small modules, ready to be used and just plumbing them together in a small way.

Thanks for the kind words though, warms my heart that someone likes it.

Re:Show HN: CLI for trying out Node.js modules easier by alehander42 on Monday March 14, 2016 @06:38AM (#11282026)
It would be very cool to detect an example from npm docs or github repo and input it initially!
Re:Show HN: CLI for trying out Node.js modules easier by tolmasky on Monday March 14, 2016 @06:51AM (#11282078)
A bunch of npm modules now provide tonicExample or tonicExampleFilename, which is used by npm/tonic try it now: https://tonicdev.uservoice.com/knowledgebase/articles/765846...
Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @08:09AM (#11282320)
That is an interesting idea, I'll see if I can implement something like that!
Re:Show HN: CLI for trying out Node.js modules easier by amelius on Monday March 14, 2016 @06:36AM (#11282019)
Next step: a try-it-on-the-web interface?
Re:Show HN: CLI for trying out Node.js modules easier by SlashmanX on Monday March 14, 2016 @06:46AM (#11282064)
Doesn't that already exist on the NPM interface? The "try it now in your browser" which links to TonicDev. Or are you suggesting something else?
Re:Show HN: CLI for trying out Node.js modules easier by amelius on Monday March 14, 2016 @07:13AM (#11282154)
In that case, why would we need a CLI tool for trying out packages?
Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @08:56AM (#11282558)
Offline capabilities + easier to use for some people (one of them being me). Loading up a webpage every time I want to try some new nodejs module would not work as well as opening up a nodejs repl with the module loaded there.
Re:Show HN: CLI for trying out Node.js modules easier by boucher on Monday March 14, 2016 @09:06AM (#11282606)
Obviously it won't work offline if you haven't already installed the package (which seems like the general case?)

I'm biased of course, and I understand why some people are turned off by an in browser solution. But I think it's probably faster, in most cases, to try something you've never installed in Tonic than in this. (And I hope there's genuine value in things like being able to share links to your experiments.)

Re:Show HN: CLI for trying out Node.js modules easier by diggan on Monday March 14, 2016 @09:15AM (#11282668)
Yeah, that is true for sure, difference being that the 10% use-case (installed package before, offline now) is still usable if it's local and not on tonic-dev.

I like tonic-dev, don't get me wrong. But the workflow for using a package in tonic-dev is too slow compared to having it in a REPL, at least for me. Might be because I'm using Firefox and the performance for tonic-dev is terrible there, but mostly because I feel more at home in the terminal than in a js-editor in the browser.

Re:Show HN: CLI for trying out Node.js modules easier by boucher on Monday March 14, 2016 @10:19AM (#11283015)
Understood. We definitely have work to do in Firefox.
Re:Show HN: CLI for trying out Node.js modules easier by benvan on Monday March 14, 2016 @07:14AM (#11282157)
I made something similar a while back : http://benvan.co.uk/js-quickload/

It only works with web libraries though. Try searching for 'moment.js'

Re:Show HN: CLI for trying out Node.js modules easier by breuleux on Monday March 14, 2016 @11:16AM (#11283291)
The online REPL for my compile-to-js language uses JSPM to load NPM packages: http://www.earl-grey.io/repl.html

Try "require: markdown", for example.

I can put up a JavaScript version if it would be useful to anyone, it's not particularly complicated.