Making node.js code to a executable file in MacOS - node.js

I have a nodejs app app.js which I'm able to execute with help of the command line tool (changing to the direction of the app and executing the command
node app.js
before that the application is installed with npm install). To make it easier in the daily use i would like to make the app executable, both parts, the installation as well as the trigger of the app.
The app is for generating a small report, I already tried it with a script where I saved the command node app.js.

You might use pkg.
This command line interface enables you to package your Node.js project into an executable that can be run even on devices without Node.js installed.

Related

How to make a Nodejs distributable command line application

I'm making a command line application with commander, inquirer and nightwatch as top dependencies. The main purpose of the app is for automation and testing.. Is there any way i can make this distributable instead of publishing it as npm package. I want the same functionality as those cli made with python, where it can be setup, and run on a target machine. is this possible? Thank you
Here are two open source projects (PKG and Nexe) that enable you to package your Node.js project into an executable:
https://github.com/zeit/pkg/blob/master/README.md
Or
https://github.com/nexe/nexe/blob/dev/README.md
You can use either one to make an executable of your project.

npm install issue with meteor custom deployment

I have used meteor build command to create a deployment bundle .tar.gz which is plain Node.js application.
I extract bundle and run following command to run app:
cd programs/server && npm install
But i am not available to run npm install, it is returning message 'SampleApplication module is not defined' and 'sampleapplication' is name of my application.
Given the error you posted, and the limited information available, I assume you're experiencing capitalization sensitivity from whatever OS your deployment server is on. Windows, Linux, OSX all handle capitalization in file paths differently.
Thus, if you develop on OSX which does not care about capitalization and deploy to a windows server which treats file paths as is you can run into issues with required file paths in your program if you are not careful.

How to make a executable from a NodeJS+Express app?

I have a NodeJS + Express app which I'm using as a Print Server.
I should create an executable from this web application.
So far, I added node-windows and node-mac to make my app run as a service or daemon.
Now what I need is, creating Windows Executable or DMG so my users can execute and start to use my app.
There are some projects like nexe (No support for Exe files) and EncloseJS but I couldn't generate a working EXE file.
What should I use for that?
The guide Standalone Express API Binaries with pkg explains how to make standalone express executables.

Building Electron with my own module

I am learning building Node modules and packaging it with Electron. I've successfully built an module out of a CPP file and can run it with node. However, to run it with Electron I need to rebuild Electron. There are instructions out there, for example:
https://github.com/electron/electron/blob/v0.37.2/docs/tutorial/using-native-node-modules.md#using-native-node-modules
https://github.com/electron/electron/issues/2330
Here I have an addon.node file after running node-gyp build. I can reference it in the node application from anywhere: var addon = require('.Release\addon'); and it works fine. However, when I build Electron with it I don't understand where to put the .node file so that it is used in the build. Before I run node_modules\.bin\electron-rebuild (see bullet point 1 link above) where should I put the addon.node file? Is it right to say that before I even test it withing Electron (with console.log or something) I need to run electron-rebuild. Is there a step that I missing that I need to take from having the addon.node file to starting to build it into Electron?
Thank you.

does a meteor.JS app compile to node.JS? If so, how

I remember hearing from someone that you can simply type in a command to compile a meteor.JS app into a node.JS app, and then deploy it as a node.JS app. Is that correct? Also, does that mean I can build a completely node.JS app by first building it in Meteor, and then using a command to compile it into node? If so, how can I do that?
You can use tool for doing that:
https://github.com/onmodulus/demeteorizer
Tutorial:
http://blog.modulus.io/demeteorizer
I believe you are looking for meteor bundle (See documentation). Meteor bundle constructs a tar.gz file from your meteor application. Once extracted, you should be able to run main.js in the extraction directory and your application built with meteor will run as a standard node application.
For clarification, here are some steps to bundle and run your node application built with meteor.
Within your meteor application directory, run:
meteor bundle appName.tar.gz
Then, unpack the bundle that meteor creates:
tar -xvzf appName.tar.gz
If the proper version of node is installed, you should be able to set your environment variables, and run the application.
export MONGO_URL='mongodb://localhost'
export ROOT_URL='http://myApp.com'
export PORT=5000
And finally, run your application. In the directory that you extracted the tar.gz file to, run:
node main.js

Resources