Standalone?

312 views
Skip to first unread message

Thomas

unread,
Jun 10, 2011, 9:22:27 AM6/10/11
to nodejs
I was wondering if node.js can be packaged as a standalone server app
for PC/Mac. For example if I built an iPhone app that connected to a
node.js server over the local network would I be able to able to
package the server as a standalone download (ie: .exe or .app) that
users can download and install on their PC/Mac and it will run in
background?

Thank you,

Thomas

Shimon Doodkin

unread,
Jun 13, 2011, 3:11:14 AM6/13/11
to nodejs
it is possible to compile static node.js,
http://fastr.github.com/articles/Node.js-on-OpenEmbedded.html
//see creating a static binary
if you build it on cygwin you don't need the whole cygwin you can just
add the cygwin .dll to the same folder.

ah.

unread,
Jun 13, 2011, 4:21:23 AM6/13/11
to nod...@googlegroups.com

Im not quite sure myself, but here are acouple more resources that seems like they say it's possible...

http://stackoverflow.com/questions/6145561/is-there-a-way-to-compile-node-js-source-files
http://code.google.com/closure/compiler/



also, there is the possibility to compile js into java classes and run as standalone compiled java.
http://bytes.com/topic/javascript/answers/424645-javascript-complier

"JavaScript is generally interpreted language, but you may use Rhino
http://www.mozilla.org/rhino/jsc.html (you must know how to invoke java
programs and how to pass a path to Rhino .jar).
It 'compiles' JavaScript files to Java classes which can be run and
therefor tested.
"


any other solutions?

thanks,
amir

Tim Smart

unread,
Jun 13, 2011, 6:39:10 AM6/13/11
to nod...@googlegroups.com
https://github.com/joyent/node/blob/master/wscript#L726-745
https://github.com/joyent/node/blob/master/tools/js2c.py

There is a start.

Tim


--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To view this discussion on the web visit https://groups.google.com/d/msg/nodejs/-/WrZUcyZG6k4J.

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.

Louis Santillan

unread,
Jun 13, 2011, 9:08:21 AM6/13/11
to nod...@googlegroups.com
IIRC, js2c.py only "compiles" JS to a C char array (aka, a string) to
be executed by V8's Script::Compile( source, name )->Run().

-L

Isaac Schlueter

unread,
Jun 13, 2011, 11:39:47 AM6/13/11
to nod...@googlegroups.com
Thomas,

What is it exactly that you want to compile into a standalone program?

Thomas

unread,
Jun 14, 2011, 12:13:32 AM6/14/11
to nodejs
I want to use it for a server app that will interact with an iphone/
ipad app over the local network. However, I would need to be able to
package the server app as a standalone .exe or .app that users can
download and install when they download the iOS app.

Is node.js a suitable solution for this?

On Jun 13, 11:39 am, Isaac Schlueter <i...@izs.me> wrote:
> Thomas,
>
> What is it exactly that you want to compile into a standalone program?
>
>
>
>
>
>
>
> On Mon, Jun 13, 2011 at 06:08, Louis Santillan <lpsan...@gmail.com> wrote:
> > IIRC, js2c.py only "compiles" JS to a C char array (aka, a string) to
> > be executed by V8's Script::Compile( source, name )->Run().
>
> > -L
>
> > On Mon, Jun 13, 2011 at 3:39 AM, Tim Smart <t...@fostle.com> wrote:
> >>https://github.com/joyent/node/blob/master/wscript#L726-745
> >>https://github.com/joyent/node/blob/master/tools/js2c.py
>
> >> There is a start.
>
> >> Tim
>
> >> On 13 June 2011 20:21, ah. <ah.ema...@gmail.com> wrote:
>
> >>> Im not quite sure myself, but here are acouple more resources that seems
> >>> like they say it's possible...
>
> >>>http://stackoverflow.com/questions/6145561/is-there-a-way-to-compile-...

Eric Muyser

unread,
Jun 14, 2011, 12:17:36 AM6/14/11
to nod...@googlegroups.com
With a little packaging, I don't see why not.

The problem I always face with packaging scripted languages is you would normally just invoke a command in CLI or run a .bat or .sh, etc. Whereas if you want a .app or .exe then you need a wrapper, like py2exe for Python. I'm not aware of any for Node.js. I'm thinking a small Python script wrapped with py2exe that invoked node, passing in your script may work. That or an Appcelerator project that invokes node and your script).

There is also a site for Node.js Windows binary (google groups keeps blocking this email), which is a number of times smoother than compiling it yourself in Cygwin imo.

Tim Caswell

unread,
Jun 14, 2011, 1:09:11 AM6/14/11
to nod...@googlegroups.com
I know that Paul Querna was working on a easy way to compile custom
node binaries. Node itself is a standalone executable. The only
thing it dynamic links is openssl which is on most posix systems.
Like others have said, bundling with certain cygwin dlls makes this
possible on windows as well. It's not ideal, but it does work.

The only thing that hasn't been done is building a custom node. It
should be pretty easy even without Paul's work. To test this theory,
simply change the JavaScript in src/node.js in the node source code.

In fact, I just looked in that file, and it seems there is a new
feature where you simply drop a js file called
lib/_third_party_main.js and it will be called instead of node's
normal startup. This requires a compile step to test, but the end
result is a single binary with your logic included.

Thomas

unread,
Jun 14, 2011, 10:59:38 AM6/14/11
to nodejs
This is very good info. Thanks everyone for answers. What are the
legalities if it were a commercial app? ie: if the iOS version were
sold for a price but the desktop version that actually uses node was
free?

Eric Muyser

unread,
Jun 14, 2011, 11:54:46 AM6/14/11
to nod...@googlegroups.com
So like a charged Mobile Mouse app that has the associated server application.

I don't see any legality issues. Node.js is MIT, you can do what you want with it. Cygwin is GPL, you can use it commercially but must distribute any changes made to it (unlikely). It's irrelevant though, the desktop application is free and wouldn't be considered part of the mobile app, if you offered it separate on the website like Mobile Mouse does (which you would undoubtably have to).

Isaac Schlueter

unread,
Jun 14, 2011, 12:26:08 PM6/14/11
to nod...@googlegroups.com
You can probably do what you want today, if you're willing to get your
hands dirty a little bit.

Put a file at lib/_third_party_main.js, and then compile node. It'll
run your _third_party_main.js file instead of it's normal main module
loading.

If you put any other files in the lib folder, they'll be there as
native modules as well. The filenames have to be compatibile with c
variable names, so use underscores rather than hyphens. So, if you
put a lib/foo.js, then in your program, you should be able to do
require("foo"). It's a little bit ghetto and overly intimate, but
that might get the job done.

License-wise, node is MIT licensed, so you can use it in commercial
for-pay projects. Read the LICENSE file in the repo. You should be
fine for almost anything you want to do, but feel free to ask here or
privately if you have specific questions.

If you want to advertise that your program uses or is built on top of
node (which is encouraged!) then you can do so, and use the name and
logo, within the terms of the trademark policy found here:
http://nodejs.org/trademark-policy.pdf Again, contact us if you have
specific questions about trademark and logo usage, but it sounds like
basically the paradigm case of nominative use.

I am much less versed in the legalities of bundling, forking, or
distributing Cygwin.

As always, this probably goes without saying: once you know what you
want to do, and you have a pretty good idea that it's probably legal,
take the relevant docs to a lawyer to review and make sure you're not
accidentally exposing yourself to risk by stepping on someone else's
IP.

Reply all
Reply to author
Forward
0 new messages