Giter VIP home page Giter VIP logo

nexe's Introduction

Build Status Downloads Version License

Install: npm i nexe -g

Nexe is a command-line utility that compiles your Node.js application into a single executable file.

Motivation and Features

  • Self contained applications
  • Ability to run multiple applications with different node.js runtimes.
  • Distribute binaries without needing node / npm.
  • Idempotent builds
  • Start and deploy faster.
  • Lockdown specific application versions, and easily rollback.
  • Flexible build pipeline
  • Cross platform builds

Usage

  • Application entrypoint:

    nexe my-app.js

  • stdin interface

    rollup -c | nexe --resource "./public/**/*" -o my-app.exe

For more CLI options see: nexe --help

Examples

  • nexe server.js -r "public/**/*.html"
  • nexe --build
  • nexe -t x86-8.0.0

Resources

Additional files or resources can be added to the binary by passing -r "glob/pattern/**/*". These included files can be read in the application by using fs.readFile or fs.readFileSync.

Compiling the nexe Executable

By default nexe will attempt to download a pre-built executable. These are listed on the releases page. The exact version you want may be unavailable or you may want to customize what is built. See nexe --help for a list of options available when passing the --build option. You will also need to ensure your environment is setup to build node. Note: the python binary in your path should be an acceptable version of python 3; you can create a symlink or use the --python parameter (e.g. nexe --build --python=$(which python3)).

Linux and macOS

Prerequisites & details

Windows

The fastest and most reliable way to get started is simply to run the commands below. If you'd rather read the details or perform a manual install of the prerequisites, you can find that here.

The instructions below are the fastest and most reliable method. Run the following sets of commands with PowerShell (running as Administrator).

Install all required build tools (and dependencies):

Set-ExecutionPolicy Unrestricted -Force
iex ((New-Object System.Net.WebClient).DownloadString('https://boxstarter.org/bootstrapper.ps1'))
get-boxstarter -Force
Install-BoxstarterPackage https://raw.githubusercontent.com/nodejs/node/master/tools/bootstrap/windows_boxstarter -DisableReboots

Set config:

npm config set msvs_version 2019
npm config set python python3.8

Where 2019 is the version of Visual Studio you have (if you have it).

Notes:

  • The above works and has been tested with node.js 14.5.4 and 15.8.0
  • Python 3 and Python 2 can coexist and nexe will still work, considering the set config area above
  • Don't use npm install windows-build-tools unless you're having some type of issue, because the above commands configures and installs the latest/preferred too.

Node.js API

Example

const { compile } = require('nexe')

compile({
  input: './my-app.js',
  build: true, //required to use patches
  patches: [
    async (compiler, next) => {
      await compiler.setFileContentsAsync(
        'lib/new-native-module.js',
        'module.exports = 42'
      )
      return next()
    }
  ]
}).then(() => {
  console.log('success')
})

NexeOptions

options: object

  • input: string

    • Input bundle file path
    • default: stdin or the current directory's main file (package.json)
  • output: string

    • Output executable file path
    • default: same as name with an OS specific extension.
  • target: string | object

    • An object or string describing platform-arch-version. e.g. 'windows-ia32-10.13.0'
      • each segment is optional, and will be merged with the current environment

      • Examples: (full list)

        • 'win32-x86-10.13.0
        • { platform: 'alpine' }
        • darwin-10.13.0
        • linux-x64
        • macos-10.13.0

        See test/target.spec.ts

    • If the build flag is set, the platform portion of the target is ignored.
    • default: process
  • bundle: string | boolean

    • If a string is provided it must be a valid relative module path and should provide an export with the following signature:
    export function createBundle (options: NexeOptions): Promise<string>
    • default: true
  • name: string

    • Module friendly name of the application
    • default: basename of the input file, or nexe_${Date.now()}
  • cwd: string

    • Directory nexe will operate on as though it is the cwd
    • default: process.cwd()
  • mangle: boolean

    • If set to false, nexe will not include the virtual filesystem (your application and resources) on the output.
    • This will cause the output to error as an "Invalid Binary" unless a userland patch alters the contents of lib/_third_party_main.js in the nodejs source.
    • default: true
  • build: boolean

    • Build node from source, passing this flag tells nexe to download and build from source. Subsequently using this flag will cause nexe to use the previously built binary. To rebuild, first add --clean
  • remote: string

    • Provide a custom remote location for fetching pre-built nexe binaries from. This can either be an HTTP or HTTPS URL.
    • default: null
  • asset: string

    • Provide a pre-built nexe binary asset, this is a file path is resolved relative to cwd.
  • python: string

    • On Linux this is the path pointing to your python3 executable
    • On Windows this is the directory where python can be accessed
    • default: null
  • flags: string[]

    • Array of node runtime flags to build node with.
    • Example: ['--expose-gc']
    • default: []
  • configure: string[]

    • Array of arguments for the node build configure step
    • Example: ['--with-dtrace', '--dest-cpu=x64']
    • default: []
  • make: string[]

    • Array of arguments for the node build make step
    • default: []
  • vcBuild: string[]

    • Options for windows build
    • default: ['nosign', 'release']
  • snapshot: string

    • path to a file to be used as the warmup snapshot for the build
    • default: null
  • resources: string[]

    • Array of globs with files to include in the build
    • Example: ['./public/**/*']
    • default: []
  • temp: string

    • Path to use for storing nexe's build files
    • Override in the env with NEXE_TEMP
    • default: ~/.nexe
  • ico: string

    • Path to a user provided icon to be used (Windows only). Requires --build to be set.
  • rc: object

    • Settings for patching the node.rc configuration file (Windows only).
    • Example (keys may vary depending on the version. Reference the file linked above):
        {
          CompanyName: "ACME Corp",
          PRODUCTVERSION: "17,3,0,0",
          FILEVERSION: "1,2,3,4"
          ...
        }
    • default: {}
  • clean: boolean

    • If included, nexe will remove temporary files for the accompanying configuration and exit
  • enableNodeCli: boolean

    • Enable the original Node CLI (will prevent application cli from working).
    • Node CLI arguments passed via the NODE_OPTIONS environment variable will still be processed. NODE_OPTIONS support can be disabled with the --without-node-options configure flag.
    • default: false
  • fakeArgv: boolean

    • fake the entry point file name (process.argv[1]). If nexe was used with stdin this will be '[stdin]'.
  • ghToken: string

    • Provide a Github Token for accessing nexe releases
    • This is usually needed in CI environments
    • default: process.env.GITHUB_TOKEN
  • sourceUrl: string

    • Provide an alternate url for the node source code
    • Note: temporary files will still be created for this under the specified version
  • loglevel: string

    • Set the loglevel, info, silent, or verbose
    • default: 'info'
  • patches: NexePatch[]

    • Userland patches for patching or modifying node source
    • default: []
  • plugins: NexePatch[]

    • Userland plugins for modifying nexe executable behavior
    • default: []

NexePatch: (compiler: NexeCompiler, next: () => Promise<void>) => Promise<void>

Patches and Plugins are just a middleware functions that take two arguments, the compiler, and next. The compiler is described below, and next ensures that the pipeline continues. Its invocation should always be awaited or returned to ensure correct behavior. Patches also require that --build be set, while plugins do not.

For examples, see the built in patches: src/patches.

NexeCompiler

  • setFileContentsAsync(filename: string, contents: string): Promise<void>
    • Quickly set a file's contents within the downloaded Node.js source.
  • replaceInFileAsync(filename: string, ...replaceArgs): Promise<void>
    • Quickly perform a replace in a file within the downloaded Node.js source. The rest arguments are passed along to String.prototype.replace
  • readFileAsync(filename: string): Promise<NexeFile>
    • Access (or create) a file within the downloaded Node.js source.
  • addResource(filename: string, contents: Buffer): Promise<void>
    • Add a resource to the nexe bundle
  • files: NexeFile[]
    • The cache of the currently read, modified, or created files within the downloaded Node.js source.

NexeFile

  • contents: string
  • absPath: string
  • filename: string

Any modifications made to NexeFile#contents will be maintained in the cache without the need to explicitly write them back out, e.g. using NexeCompiler#setFileContentsAsync.

Native Modules

In order to use native modules, the native binaries must be shipped alongside the binary generated by nexe.

Troubleshooting

Error: Entry file "" not found! means you need to provide nexe with input. Either use -i or pipe data to it.

Error: https://github.com/nexe/nexe/releases/download/v3.3.3/windows-x64-15.8.0 is not available, create it using the --build flag or similar message means that it either:

  • You are having networking issues such as the download being blocked
  • You should specify the target so nexe knows what version of the executable to use.
    • See the releases page to find the executable's version number
    • Example
      • nexe -i "app.js" -r "public/**/*.html" -o "dist/myApp.exe" -t x64-14.15.3
      • where -i specifies the input, -r specifies resources to embed, -o specifies the output, -t specifies the target.
    • Alternatively you can compile the executable yourself, see that section for details

Contributing

Building

$ git clone [email protected]:nexe/nexe.git
$ cd nexe
$ npm i && npm run build

Testing

$ npm test

nexe's People

Contributors

alexwhitman avatar anmonteiro avatar aral avatar bmaupin avatar bruce-one avatar caffeinewriter avatar calebboyd avatar ckarper avatar enko avatar foxever avatar gitter-badger avatar jackdoe avatar jamesmgreene avatar jaredallard avatar jhbruhn avatar jontore avatar kevgo avatar lahdekorpi avatar lorenzgardner avatar mt-sergio avatar nathan818fr avatar overra avatar royra avatar samyakbhuta avatar silviom avatar tallesl avatar tm1000 avatar varatep avatar vilicvane avatar wilmardo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nexe's Issues

Windows: "Unexpected token ILLEGAL" by not escaping paths

Hi! Cool project.

I tried to run it on windows, on a project containing an npm dependency (xml2js). However, the compiled binary dies immediately with the error:

nexe.js:78
var xmljs = require("C:\Users\redacted\...\node_modules\xml2js\lib\xml2js.js");
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected token ILLEGAL
    at NativeModule.compile (node.js:899:14)
    ...

This is caused by the simulated path to my npm dependency (xml2js) containing JS escape sequences like \r and \x.

There should be a JSON.stringify() call inserted somewhere, to properly escape the path when patching the file.

No complication step?

Before I go try to add this feature I thought I'd ask.

Why even have a complication step? I'm fine if my node app runs uncompiled. All I want is some kind of installable executable that has all my apps files installed in some folder and then runs the version of node embedded in those files with the right command.

Is that a feature/option that would be good for nexe? Something like --no-compile

Path resolution

Hi,

Locally installed nexe (npm install nexe), and "hello.js" in the same dir. I need to use this command:

 node_modules/nexe/bin/nexe -i ../../../hello.js -o hello

instead of:

 node_modules/nexe/bin/nexe -i ./hello.js -o hello

Maybe you can fix path resolution... Or maybe I can help (I will fork repo because I think your project is very attractive)

Best regards

needed dependencies

Hi,
It seems (on Fedora 17) that this dependecies are needed in package.json:

  • mkdirp
  • stepc
  • async
  • crc32

Regards

Build doesn't complete

I'm testing nexe in the hope that we can use it to package some of our apps and I can't seem to get it to work. As a test I've got an index.js file containing just

console.log('hello');

Running nexe -r "0.10.15" it dumps out the below and then doesn't appear to do anything:

$ nexe -r "0.10.15"
downloading node 0.10.15
unzipping node source
making application bundle with /home/alex/projects/nexetest/index.js
writing application bundle:

(function() {
    var modules = {}, definitions = {};
    var _require = function(path) {
        if (modules[path]) return modules[path];
        var module = {
            exports: {}
        }, definition = definitions[path];
        if (!definition) {
            try {
                return require(path);
            } catch (e) {}
            throw new Error("unable to load " + path);
        }
        return modules[path] = module.exports = definition(_require, module, module.exports, path);
    };
    var define = function(path, definition) {
        definitions[path] = definition;
    };
    if (typeof global == "undefined") {
        global = window;
    }
    if (typeof window == "undefined") {
        global.window = global;
    }
    if (typeof window.process == "undefined") {
        window.process = {};
    }
    if (typeof document == "undefined") {
        global.document = global;
    }
    if (typeof document.documentElement == "undefined") {
        document.documentElement = {};
    }
    if (typeof document.documentElement.style == "undefined") {
        document.documentElement.style = {};
    }
    if (typeof navigator == "undefined") {
        global.navigator = global;
    }
    if (typeof navigator.userAgent == "undefined") {
        navigator.userAgent = "sardines";
    }
    if (typeof navigator.platform == "undefined") {
        navigator.platform = "sardines";
    }
    define("/home/alex/projects/nexetest/index0js", function(require, module, exports, __dirname, __filename) {
        console.log("hello");
        return module.exports;
    });
    var entries = [ "/home/alex/projects/nexetest/index0js" ];
    for (var i = entries.length; i--; ) {
        _require(entries[i]);
    }
})();


monkey patching node.js file
building node.js
../deps/cares/src/ares_process.c: In function ‘read_udp_packets’:
../deps/cares/src/ares_process.c:481:35: warning: pointer targets in passing argument 6 of ‘recvfrom’ differ in signedness [-Wpointer-sign]
In file included from /usr/include/x86_64-linux-gnu/sys/socket.h:281:0,
                 from ../deps/cares/src/ares_process.c:21:
/usr/include/x86_64-linux-gnu/bits/socket2.h:64:1: note: expected ‘socklen_t * __restrict__’ but argument is of type ‘ares_socklen_t *’

Thinking it might just be taking a while to compile node, I compiled another instance of node and that finished in about 11 minutes. nexe has been running for over 30 minutes. What am I missing?

broken nexe --version

I attempted to do a nexe --version to provide the info in another bug report, but... it's broken.

module.js:340
    throw err;
          ^
Error: Cannot find module '/home/talles'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.require.resolve (module.js:384:19)
    at Object.exports.compile (/home/talles/node_modules/nexe/lib/index.js:21:23)
    at Object.<anonymous> (/home/talles/node_modules/nexe/bin/nexe:46:19)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)

:-(

sardines has no method 'package'

I just found this project and it looks great. I installed it with npm on ubuntu linux with devtools setup ok (I have already compiled node for another project). I was not sure exactly how to proceed so I created a directory:-

node_modules
- nexe
nexe-test
- test.js

test.js has following code:- console.log("hello from nexe");

I then changed directory to nexe-test and did: sudo ../node_modules/nexe/bin/nexe -i test.js -o app.nex
It kept giving an error of a certain module not being found so each time I just did npm install and then it complained of the next module. After a while it ran and downloaded node-v0.6.3 but then gave the error:-

Result is as follows:-

sudo ../node_modules/nexe/bin/nexe -i test.js -o app.nex

 /home/simon/Documents/node_modules/nexe/lib/index.js:201
    sardines.package({ input: entries, include: include, output: node.libDir + '
                    ^
 TypeError: Object function (ops, next) {



/**
 * first analyze the dependencies. This works a few ways:
 *
 * 1. dir specified, so scan ALL scripts, including third-party modules.
 * 2. entry point specified, so scan ONLY scripts which are used ~ (look for require() stmts)
 */

var include = [ops.entry].concat(ops.include || []),
buildId = ops.buildId || Date.now();



analyzeDeps({ entries: include }, outcome.error(next).success(function(deps) {


    if(ops.method == "shrinkwrap") {
        combineScripts.shrinkwrap({
            include: deps,
            entries: [deps[0]],
            buildId: buildId
        }, next);
    } else 
    if(ops.method == "browserify") {
        combineScripts.browserify({
            wrap: ops.wrap,
            include: deps,
            directory: ops.directory,
            buildId: buildId
        }, next)
    } else 
    if(ops.method == "wrap") {
        combineScripts.wrap({
            entry: deps[0]
        }, next);
    }


}));
 } has no method 'package'
 at /home/simon/Documents/node_modules/nexe/lib/index.js:201:19
 at onComplete (/home/simon/Documents/node_modules/nexe/lib/index.js:63:3)
 at prepare (/home/simon/Documents/node_modules/nexe/lib/index.js:70:40)
 at Object.exports.compile (/home/simon/Documents/node_modules/nexe/lib/index.js:168:2)
 at Object.<anonymous> (/home/simon/Documents/node_modules/nexe/bin/nexe:27:19)
 at Module._compile (module.js:454:26)
 at Object.Module._extensions..js (module.js:472:10)
 at Module.load (module.js:356:32)
 at Function.Module._load (module.js:312:12)
 at Module.runMain (module.js:497:10)

How can I proceed, do you have an example app that you have compiled so I can see your idea of how to use the module?

building examples fails from the project top

I can compile the examples correctly if I go into the examples/ directory.
But when stay in the top gitrepo root , when I try to compile the examples, I get some errors (for the index.js example only)

$ ./bin/nexe -i ./examples/hello-world/browser.js -o browser
$ ./browser
hello browser!
$ ./bin/nexe -i ./examples/hello-world/index.js -o index
$ ./index

nexe.js:0
(null)

Error: unable to load nexe
    at _require (nexe.js:12:19)
    at entries (nexe.js:29:20)
    at _require (nexe.js:14:49)
    at nexe.js:39:9
    at nexe.js:41:3
    at NativeModule.compile (node.js:619:5)
    at Function.NativeModule.require (node.js:587:18)
    at Function.Module._load (module.js:297:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)

In the generate code I see:

 define("91fddc0f/index.js", function(require, module, exports, __dirname, __filename) {
     var http = require("nexe");
     var fs = require("fs"), path = require("path"), port = 1337;

The http require has been replaced by nexe. It seems that this sardines doing.
It takes the name from the package.json file in the top root. (nexe)

nodejs fs module not loading

After compiling a project that uses the fs module, it appears to be coming out as an empty object in the compiled version.

var fs = require('fs');
console.log(fs);

produces the output: {}, instead of all of the methods and things that should be on the normal fs object.

Could this be something that browserify is doing (since obviously the 'fs' module would be unavailable in a module)?

Native addon support - aka, faking dlopen?

Hey.

So since a while now, I have tried my luck with nodejs modules - especially native addons. It turns out that those are nothing but dynamic libraries (well lol, who would have guessed?).

In order to implement support for these in nexe, one would have to either fake the dlopen function and point it BACK at the executable. Buuuut, that may be no good idea entirely... So I got another idea.

Since nodejs does not offer a real way to do manual memory management, and hence can not read binary data off memory, or require() it from there, there is the option to dynamicaly extract the shared objects, and then require them. That is, if we have no other choice.
But if you find a way to place the .node file into meory and trick require in reading it, then you would get what you want.

In PHP, one can use stream wrappers to do that. I dont know is there is such a way for nodejs though.

But I thought I would share my opinion and thought on this, as I am needing this functionality myself currently o.o

Kind regards, Ingwie

tar: \tmp\nexe\\latest: Cannot chdir: No such file or directory

I use:
node v0.10.28
express 4.2.0

do step:
step 1:
npm install nexe

step 2:
nexe -i ./bin/www -o 1.exe

----> tar -xf \tmp\nexe\latest\node-latest.tar.gz -C \tmp\nexe\latest
tar: \tmp\nexe\latest: Cannot chdir: No such file or directory
tar: Error is not recoverable: exiting now
stdout: Broken pipe

Cannot find module 'myproject.js'

Is there something I have to add to my project so that nexe will recognize it. When I try to do something like: nexe -i myproject.js -o myproject.bin -r 0.0.9 I get this error:

module.js:340
throw err;
^
Error: Cannot find module 'myproject.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._compile.require.resolve (module.js:382:19)
at Object.exports.compile (/usr/local/lib/node_modules/nexe/lib/index.js:21:23)
at Object. (/usr/local/lib/node_modules/nexe/bin/nexe:40:19)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

Error when trying to compile

I get the following error.

Error: Cannot find module './lib-cov/express'

Looking in the path it is after there is a /lib/express but no lib-cov/

Any ideas what is going wrong there?

Windows problem when try to complie peerflix

Hi, when im trying to complie "peerflix" project the complie stuck in v8_base.vcxproj -> ........\build\Release\lib\v8_base.lib, and dont do nothing, i do the same with "torrent-stream" stuck in v8_base.vcxproj -> ........\build\Release\lib\v8_base.lib too, what is happen? dont show any error or nothing

I have been compiling the examples hellow world and works ok, i have phyton 7 and visual studio 2013

path join error when compiling

I keep getting this error when compiling. Doesn't seem to make a difference what arguments I use in my 2 line compile.js file for input, output, flags, etc.

path.js:360
throw new TypeError('Arguments to path.join must be strings');
^
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at Object.exports.join (path.js:358:36)
at _downloadNode (/Users/lukeandkimberlee/node_modules/nexe/lib/exe.js:97:25)
at downloadNode (/Users/lukeandkimberlee/node_modules/nexe/lib/exe.js:33:4)
at fn (/Users/lukeandkimberlee/node_modules/async/lib/async.js:583:34)
at Object._onImmediate (/Users/lukeandkimberlee/node_modules/async/lib/async.js:499:34)
at processImmediate as _immediateCallback

nexe is using wrong directory name

I'm using nexe through command line (simple stuff, nexe -i myjs.js -o myjs) and I got the following error:

ENOENT, open '/tmp/nexe/node-latest/lib/nexe.js'

After that (the tmp folder was clean before, I've checked) there is node-latest.tar.gz and a folder named node-v0.10.23 on the tmp folder.

The folder name inside the .tar.gz file uses the current version of node, and not simply node-latest as nexe is attempting to use.

Unable to execute if package.json present

I must be missing something from my package.json, because when I build with the package.json in place, it builds fine, but when I execute I get:

nexe.js:12
        throw new Error("unable to load " + path);

If I however do this

mv package.json pkg.json
nexe -i index.js -o app.bin
mv pkg.json package.json

everything works fine...!?

Here is my package.json

{
  "name": "app",
  "version": "0.0.1",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/asbjornenge/app.git"
  },
  "author": "Asbjorn Enge <[email protected]>",
  "license": "BSD-2-Clause",
  "bugs": {
    "url": "https://github.com/asbjornenge/app/issues"
  },
  "dependencies": {
    "lodash": "~2.4.1"
  }
}

--flags does not work

Compiling with --flags doesn't work as intended; flags are being captured by Node. I tried using v0.8.15 as specified in this example, but this didn't work either. I understand the monkeypatching might require some particular version(s). Any idea?

Set user-agent when downloading node runtime

My company uses web filtering software that will block just about any HTTP connection that doesn't look like a web browser. When you try to reach a server outside the company network over HTTP in a non-browser, they will intercept the request and respond with an HTML page telling you that the request has been blocked.

As you might imagine, this causes a problem when trying to use nexe because the downloaded node-latest.tar.gz file isn't a tar at all – it's the HTML of the company's "block" page.

----> downloading http://nodejs.org/dist/node-latest.tar.gz
[==================================================================]
----> tar -xf /tmp/nexe/latest/node-latest.tar.gz -C /tmp/nexe/latest
tar: Unrecognized archive format
tar: Error exit delayed from previous errors.

In npm, I was able to get around this by spoofing the user-agent string to look like a web browser. Would it be possible to specify a user-agent in nexe somehow?

Express app

Hi, i'm try to compile and run sample express3 app within nexe.
But have error!
Here's my steps to create app:

express test-server
cd test-server
npm install

Then i've compiled it

nexe -i ./app.js -o ./app.nex -r 0.8.18

So 10Mb size app.nex was generated. But, when i run it i have an error, such as:

$ ./app.nex
nexe.js:1103
        throw new Error('no window object present');
              ^
Error: no window object present

Windows Version

It would be cool if it made a windows .exe file. But maybe that is not in the plans :-)

Error when executing obtained binary (Fedora 20, 64 bits)

nexe.js:12
throw new Error("unable to load " + path);
^
Error: unable to load undefined
at _require (nexe.js:12:19)
at nexe.js:48:9
at nexe.js:50:3
at NativeModule.compile (node.js:900:5)
at Function.NativeModule.require (node.js:869:18)
at Function.Module._load (module.js:297:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at [eval]:1:1
at Object. ([eval]-wrapper:6:22)

Windows support, extended OS X support, binary addons

Hey hey. Instead of making it three seperate issues, I thought i'd make one.

Windows support
So, when is this coming? i am getting to a point where I have about six extensions, that all need to reside inside the actual nodejs binary. But, the main userbase is on Windows...

Extended OS X support
I saw an issue about OS X .app packages? They're hillariously easy. You'll just need an actual Info.plist file, and that can be looked up from across the internet. But to create a base .app package:

# Assuming we're inside the release folder and $APPNAME is the file of the executable, application, whatever...
mkdir -p $APPNAME.app/Contents/MacOS
cp $APPNAME $APPNAME.app/Contents/MacOS/$(basename $APPNAME) #no extension!
cp Info.plist $APPNAME.app/Contents/Info.plist

The most important keys for the Info.plist file would be the executable name, application name, application display name, version, copyright and idendifyer. As long as you do not use Cocoa in any way, you won't need it...but if you do, then you need to also mkdir $APPNAME.app/Contents/Resources.
Thats it, app bundle. :)

Binary addons
Binary addons are something very important - especially as I am making an FLTK wrapper - so I need to link in the library file. A usual invocation of such is:
g++ myApp.cpp -lfltk ...obviously I shortened that a bit.
But, when creating a nodejs executable with a binary addon, there are two things to consider:

  • Adding the library and its objects - or adding just a link to the shared library.
  • Adding the actual addon.node binary.

I think that especialyl the second is not ultra-easy. But one method I can think about is: Unpack the extension in memory thru another module. Like, serialize the module in memory, and tell nodejs to use it from there. That'd make it a simple .js file again. Buuuut, the next problem then is that you'll need to compile the addon before compiling a "nexe".
A bit complicated, but think about that - it may actually work.

// this is pseudo-code.
var bin = [...binary content...],
binInMemory = putIntoMemory(bin);
module.exports = require(binInMemory);

Kind regards, Ingwie.

Obfuscate app

How obfuscated is the code produced by nexe? I presume the source is inlined somewhere? or is this using v8snapshots? I'm looking into selling an application and I'd like some kind of protection from pirates. Just minifying should be enough, however the based off the result of sardines the module layout is still quite discernable. Any ideas :)?

Stuck on building node.js

This is the output given from running >nexe -i <.jsFile> -o

writing application bundle: 

(function() {
    var modules = {}, definitions = {};
    var _require = function(path) {
        if (modules[path]) return modules[path];
        var module = {
            exports: {}
        }, definition = definitions[path];
        if (!definition) {
            try {
                return require(path);
            } catch (e) {}
            throw new Error("unable to load " + path);
        }
        return modules[path] = module.exports = definition(_require, module, module.exports, path);
    };
    var define = function(path, definition) {
        definitions[path] = definition;
    };
    if (typeof global == "undefined") {
        global = window;
    }
    if (typeof window == "undefined") {
        global.window = global;
    }
    if (typeof window.process == "undefined") {
        window.process = {};
    }
    if (typeof document == "undefined") {
        global.document = global;
    }
    if (typeof document.documentElement == "undefined") {
        document.documentElement = {};
    }
    if (typeof document.documentElement.style == "undefined") {
        document.documentElement.style = {};
    }
    if (typeof navigator == "undefined") {
        global.navigator = global;
    }
    if (typeof navigator.userAgent == "undefined") {
        navigator.userAgent = "sardines";
    }
    if (typeof navigator.platform == "undefined") {
        navigator.platform = "sardines";
    }
    define("/home/jasper/workspace/Languages/javascript/node-webkit-project-manager/projectmake0js", function(require, module, exports, __dirname, __filename) {
        var index = 0, val = "node";
        console.log("commandArg" + index + ": " + val);
        return module.exports;
    });
    var entries = [ "/home/jasper/workspace/Languages/javascript/node-webkit-project-manager/projectmake0js" ];
    for (var i = entries.length; i--; ) {
        _require(entries[i]);
    }
})();


monkey patching node.js file
building node.js

After waiting 30 mins, still nothing was happening. I will be looking into how the node.make() function to see what is making it hang like this but any other help would be most appreciated.

parsing command arguments issue

i'm trying to compile my command tools in single binary file by following command

nexe -i cci.js -o cci.o

everything is good, except the arguments pass from command console.

[root@host ssh.js]# ./cci.o -m cmd.ls -k '*' // error
Error: unrecognized flag -m
Try --help for options
cci : version 0.7.0

Options:
-m, --method Mangerment console
[ cmd.(ls/add/get/mod/del/man/chgrp/edit/exec) ]
[ file.(ls/add/get/mod/del/man/chgrp) ]
-k, --key Key for mangerment console
-f, --file source file for script or file method
--desc, --desc comment for script
--name, --name specified with new scrip

[root@host ssh.js]# ./cci.o "any of string" -m cmd.ls -k '*' // this one run correct
xj/cci | 2014-01-07 02:42:35 | 52.8K | added at 2014-01-07 23:48:23
xj/ec-swapdetect | 2014-01-07 20:50:12 | 0.05K | added at 2014-01-07 23:42:59
xj/cci.js | 2014-01-07 02:34:09 | 52.5K | added at 2014-01-07 02:30:29
xj/tlog | 2014-01-07 02:34:26 | 0.06K | find latest log
xj/create_swap_partition.sh | 2014-01-07 21:29:55 | 0.49K | added at 2014-01-07 23:42:13
users/ssh.js | 2014-01-07 02:32:48 | 37.1K | ssh batch nodejs script
users/xj.int.sh | 2014-01-07 02:33:27 | 0.15K | it's test interactive script
users/hiconfig.sh | 2014-01-07 02:33:40 | 3.3K | hiconfig

Overzealous require() substitutions

Hi, there is a problem with string substitutions being overzealously applied in nexe.

Example 1:

var fs = require('fs'); var http = require('http'); becomes var fs = require('myapp.js'); var http = require('myapp.js'); which is just wrong.

Example 2:

Also later on, using "fs" or "http" as string constants also become erroneously replaced, e.g. if (protocol_used = "http") becomes if (protocol_used = "myapp.js") . This is quite bad. The replacements should err on the side of missing replacements rather than blindly every single usage of the string.

This is causing any project that depends on node fs/http libraries to fail (and i assume the problem exists with other builtin libraries)

Parsing error

I'm trying to compile an application converted from CoffeeScript to JS (using coffee -c).

After solving all dependencies, I get the following error:

Unexpected token: string (underscore) Error at new JS_Parse_Error (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:263:18) at js_error (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:271:11) at croak (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:733:9) at token_error (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:740:9) at unexpected (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:746:9) at Object.semicolon [as 1] (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:766:43) at prog1 (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:1314:21) at simple_statement (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:906:27) at /usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:814:19 at block_ (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:1003:20) at function_ (/usr/lib/node_modules/nexe/node_modules/sardines/node_modules/uglify-js/lib/parse-js.js:982:31)

Any idea?
Thanks in advance, much appreciated!

Display help on -h and --help flags

When running the nexe CLI tool, with -h or --help it tries to compile and generate a *.new file for the current directory.

Expected behaviour: display helpful messages and perform zero tasks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.