5

I would like to "compile" all my big node.js project into one huge javascript file that I then can run it with node index.js and works out of the box.

Thanks

Totty.js
  • 15,563
  • 31
  • 103
  • 175
  • 1
    I'm interested, why? Generally doing this server-side will have no effect on anything. – loganfsmyth Mar 20 '14 at 06:24
  • 1
    I have some apps that have to be hosted on the client's host. Therefore minimizing and encrypting the node.js part would make more difficult to make changes to the server side part. Also I've always liked the idea of having one file with all, so I don't have to worry about the node_modules to stay at the same version as in my machine. (You might know that you almost never have the same packages, if you don't include them in git too) – Totty.js Mar 20 '14 at 09:12

1 Answers1

0

You can do this with Browserify. Use the --bare option to leave out browser versions of Node.js modules.

https://github.com/substack/node-browserify

Brad
  • 159,648
  • 54
  • 349
  • 530
  • I get this error: "Error: module "./lib-cov/express" not found from... my index.js" – Totty.js Mar 19 '14 at 16:10
  • @Totty Depending on your application, you may need to exclude those libraries. Use `--ignore express/lib-cov` or `--ignore lib-cov/express` (I forget which). You will need to do the same with Connect, and likely Jade. Those libraries are just for testing anyway. – Brad Mar 19 '14 at 16:19
  • But why is not possible to be included in the minified file? – Totty.js Mar 19 '14 at 16:41
  • @Totty It is possible if you install those files, but they simply aren't needed. If you Google for this problem, you will see many results with a full explanation. – Brad Mar 19 '14 at 17:05