Giter VIP home page Giter VIP logo

pmq20 / node-packer Goto Github PK

View Code? Open in Web Editor NEW
3.1K 79.0 202.0 159.51 MB

Packing your Node.js application into a single executable.

License: MIT License

Ruby 0.01% Makefile 0.04% Shell 0.07% R 0.01% JavaScript 5.62% HTML 5.55% C++ 29.42% Python 2.77% C 12.53% Objective-C 0.13% Perl 17.81% CMake 0.01% Batchfile 0.02% CSS 0.02% Assembly 25.94% DIGITAL Command Language 0.01% M4 0.04% eC 0.01% Scheme 0.01% Lua 0.01%
nodejs squashfs linux macos windows libsquash enclose-io

node-packer's Introduction

Node.js Packer

Packing your Node.js application into a single executable.

Windows macOS Linux

Features

It takes less than 5 minutes to compile any project with node-packer.

You won't need to modify a single line of code in your application, no matter how you developed it as long as it works in plain node.js!

  • Works on win Windows, macOS macOS and linux Linux
  • Creates a binary distribution of your application
  • Supports natively any form of require, including dynamic ones (e.g. require(myPath + 'module.js')
  • Native C++ modules are fully supported
  • Open Source, MIT Licensed

Download

Stable Releases

Here is the latest stable Node.js Packer release:

OS Arch. Executable
Windows x64 https://gw.alipayobjects.com/os/enclose-prod/0d0ec8fd-dc9c-4b0a-85df-8bf4af0e8b8d/nodec-v1.5.0-x64.zip
macOS x64 https://gw.alipayobjects.com/os/enclose-prod/bc2022ef-4b88-4c12-9980-394945c9c198/nodec-v1.5.0-darwin-x64.gz
Linux x64 https://gw.alipayobjects.com/os/enclose-prod/b6aa41a6-f6b5-4542-b777-06e4bc292c5e/nodec-v1.5.0-linux-x64.gz

Unstable Pre-release

Whenever the master branch CI succeeded, a Node.js Packer pre-release binary would be automatically generated. Here is the latest unstable pre-release build:

OS Arch. Executable
Windows x64 https://github.com/pmq20/node-packer/releases/download/windows-x64/pre-release-nodec-v140800.121803-x64.exe
macOS x64 https://github.com/pmq20/node-packer/releases/download/darwin-x64/pre-release-nodec-v140800.121803-darwin-x64
Linux x64 https://github.com/pmq20/node-packer/releases/download/linux-x64/pre-release-nodec-v140800.121803-linux-x64

Install

win Install on Windows

First install the prerequisites:

Then download nodec-x64.exe.

Optionally, put it under C:\Windows or any other PATH directories. Open Visual Studio's "x64 Native Tools Command Prompt" and execute nodec --help therein.

macOS Install on macOS

First install the prerequisites:

  • SquashFS Tools 4.3: brew install squashfs
  • Xcode
    • You also need to install the Command Line Tools via Xcode. You can find this under the menu Xcode -> Preferences -> Downloads
    • This step will install gcc and the related toolchain containing make
  • Python 2.6 or 2.7
  • GNU Make 3.81 or newer

Then download nodec-darwin-x64.

Run chmod +x to give it execution permissions and execute ./nodec --help.

Additional Notes on Build failure in macOS XCode 11

According to recent Travis Build, the test cases will fail shortly after its launch occurs when the Build Environement is XCode 11. Currently, it is not known whether the issue is caused by XCode 11 or other factors within Travis CI that may not impact on actual macOS deployment.

Therefore, the build environment for macOS under Travis is XCode 10.2 so as to ensure the test case can be successfully executed and completed.

linux Install on Linux

First install the prerequisites:

  • SquashFS Tools 4.3
    • sudo yum install squashfs-tools
    • sudo apt-get install squashfs-tools
  • gcc and g++ 4.9.4 or newer, or
  • clang and clang++ 3.4.2 or newer
  • Python 2.6 or 2.7
  • GNU Make 3.81 or newer

Then download nodec-linux-x64.

Run chmod +x to give it execution permissions and execute ./nodec --help.

Additional Notes on the compatibility between RHEL based (CentOS) / Ubuntu

It is known that the default repo for Red Hat and CentOS distros contains a very outdated gcc / g++ (3.8.5) while the latest Long Term Support (LTS) of Ubuntu as of 15 Feb 2018 (Ubuntu 18.04 LTS) contains a relatively updated gcc / g++ (7.3.0).

It is known that compilation can fail when using unsupported configuration where the version of prerequisites is older than prescribed.

Therefore, it is crucial for the users of Red Hat based distros to install gcc / g++ outside from official repos. For starters, one may look at:

Additionally, binaries that are compiled from Ubuntu 18.04 LTS is known NOT to work in Red Hat 7 based distro (Including CentOS) due to 'glibcxx_3.4.20' not found' related error. However, binaries that are compiled from either Red Hat or CentOS 7 are known to work with Ubuntu 18.04 LTS based on my internal experiment.

Having said that, I will still recommend that binaries distributors should compile 2 versions for Linux where one caters for RHEL based and the other for Ubuntu based.

Additional Notes on Build failure in Linux

According to recent Travis Build, Linux has been failing to build since nodec-1.6.0-10.16.0 (Node.js 10.16.0). The root cause is yet to be determined, and the last known good build is 10.15.3 which can be downloaded here: https://github.com/slee047/node-packer/releases/tag/1.6.0-10.15.3-1

The issue can be found here: https://github.com/slee047/node-packer/issues/11

NOTE: This gz file (nodec-darwin-x64.gz) contains an outdated version of nodec (nodec 1.5.0 with Node.js 8.3.0). The original maintainer did not specify how to build this repo into single executable, therefore newer versions can only be run on source code directly.

Usage

nodec [OPTION]... [ENTRANCE]
      --current                    Uses the current Node.js release
      --lts                        Uses the LTS Node.js release
  -r, --root=DIR                   Specifies the path to the root of the application
      --output=FILE                Specifies the path of the output file
  -d, --tmpdir=DIR                 Specifies the directory for temporary files
      --clean-tmpdir               Cleans all temporary files that were generated last time
      --keep-tmpdir                Keeps all temporary files that were generated last time
      --make-args=ARGS             Passes extra arguments to make
      --vcbuild-args=ARGS          Passes extra arguments to vcbuild.bat
  -n, --npm=FILE                   Specifies the path of npm
      --skip-npm-install           Skips the npm install process
      --debug                      Enables debug mode
  -o, --dest-os=OS                 Specifies the destination operating system (enum: win mac solaris freebsd openbsd linux android aix)
  -a, --dest-arch=ARCH             Specifies the destination CPU architecture (enum: arm arm64 ia32 mips mipsel ppc ppc64 x32 x64 x86 s390 s390x)
      --quiet                      Enables quiet mode
  -v, --version                    Prints the version of nodec and exit
  -h, --help                       Prints this help and exit

Note: if ENTRANCE was not provided, a single raw Node.js interpreter executable would be produced.

Note: To compile to 32-bit windows OS compatible programs on a 64-bit machine, you should use a x64 x32 cross compiling environment. You should be able to find it in your Start Menu after installing Visual Studio. Also, you have to use a 32-bit Node.js, because the arch information is detected via node -pe process.arch.

Examples

Compile a CLI tool

git clone --depth 1 https://github.com/jashkenas/coffeescript.git
cd coffeescript
nodec bin/coffee
./a.out (or a.exe on Windows)

Compile a web application

git clone --depth 1 https://github.com/eggjs/examples.git
cd examples/helloworld
npm install
nodec node_modules/egg-bin/bin/egg-bin.js
./a.out dev (or a.exe dev on Windows)

Learn More

How it works

Comparing with Similar Projects

Project Differences
pkg Pkg hacked fs.* API's dynamically in order to access in-package files, whereas Node.js Packer leaves them alone and instead works on a deeper level via libsquash. Pkg uses JSON to store in-package files while Node.js Packer uses the more sophisticated and widely used SquashFS as its data structure.
EncloseJS EncloseJS restricts access to in-package files to only five fs.* API's, whereas Node.js Packer supports all fs.* API's. EncloseJS is proprietary licensed and charges money when used while Node.js Packer is MIT-licensed and users are both free to use it and free to modify it.
Nexe Nexe does not support dynamic require because of its use of browserify, whereas Node.js Packer supports all kinds of require including require.resolve.
asar Asar keeps the code archive and the executable separate while Node.js Packer links all JavaScript source code together with the Node.js virtual machine and generates a single executable as the final product. Asar uses JSON to store files' information while Node.js Packer uses SquashFS.
AppImage AppImage supports only Linux with a kernel that supports SquashFS, while Node.js Packer supports all three platforms of Linux, macOS and Windows, meanwhile without any special feature requirements from the kernel.

Cross Compilation

nodec also support cross-compilation. Since node.js is built from sources you will need to setup properly a toolchain in order to get valid compilers to produce binaries for the destination platform.

You can easily do this with by using crosstool-ng or any other tool you like.

Once you're done with the build of a valid toolchain (don't forget to enable c++ if you use crosstool-ng which by default excludes it) you will be able to compile properly. Just set-up your environment so that it will know to use your cross-compile toolchain rather than your system's default build tools.

An example (you may need to adjust values or specify additional variables):

export AR="x86_64-unknown-linux-gnu-ar"
export CC="x86_64-unknown-linux-gnu-gcc"
export CXX="x86_64-unknown-linux-gnu-g++"
export LINK="x86_64-unknown-linux-gnu-g++"
export CPP="x86_64-unknown-linux-gnu-gcc -E"
export LD="x86_64-unknown-linux-gnu-ld"
export AS="x86_64-unknown-linux-gnu-as"
export CCLD="ax86_64-unknown-linux-gnu-gcc ${TARGET_ARCH}"
export NM="x86_64-unknown-linux-gnu-nm"
export STRIP="x86_64-unknown-linux-gnu-strip"
export OBJCOPY="x86_64-unknown-linux-gnu-objcopy"
export RANLIB="x86_64-unknown-linux-gnu-ranlib"
export F77="x86_64-unknown-linux-gnu-g77 ${TARGET_ARCH}"
unset LIBC

#Define flags
#export CXXFLAGS="-march=armv7-a"
export LDFLAGS="-L${CSTOOLS_LIB} -Wl,-rpath-link,${CSTOOLS_LIB} -Wl,-O1 -Wl,--hash-style=gnu"
export CFLAGS="-isystem${CSTOOLS_INC} -fexpensive-optimizations -frename-registers -fomit-frame-pointer -O2 -ggdb3"
export CPPFLAGS="-isystem${CSTOOLS_INC}"
# export CCFLAGS="-march=armv7-a"

#Tools
export CSTOOLS=/Volumes/crosstools/x86_64-unknown-linux-gnu
export CSTOOLS_INC=${CSTOOLS}/include
export CSTOOLS_LIB=${CSTOOLS}/lib
#export ARM_TARGET_LIB=$CSTOOLS_LIB
# export GYP_DEFINES="armv7=1"

#Define other things, those are not 'must' to have defined but we added
export SHELL="/bin/bash"
export TERM="screen"
export LANG="en_US.UTF-8"
export MAKE="make"

#Export the path for your system
#export HOME="/home/gioyik" #Change this one with the name of your user directory
export PATH=${CSTOOLS}/bin:/usr/arm-linux-gnueabi/bin/:$PATH

To-do

  • Eliminate dependending on an outside Node.js and npm when compiling
  • Be able to use a custom icon and file description for the executable output. maybe an icon file in the package root directory.
  • Add options to select items to deliver
    • Ppt out zlib/openssl for system libraries
    • Incl and ICU
    • Debug facilities
  • Add options to select compression-method
    • Optionally xz the final product
  • Detect simultaneous runs of nodec
  • Warn the user that some symbolic link links to the outside of the project
    • Add a check procedure at compile time
    • #37
  • Cross-compile
    • #36
    • Support ARM architecture
    • #26
  • Make Docker images for compiler environments
  • Generate Windows-less Cmd-less Windows applications via /subsystem=windows
  • Drop the external dependency of mksquashfs
    • i.e. Give libsquash the ability to mksquashfs
  • Support library only projects

Authors

Minqi Pan et al.

License

MIT

See Also

  • Libsquash: portable, user-land SquashFS that can be easily linked and embedded within your application.
  • Squashfs Tools: tools to create and extract Squashfs filesystems.

node-packer's People

Contributors

ibigbug avatar lexor90 avatar pmq20 avatar roytan883 avatar slee047 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

node-packer's Issues

Unable to compile my js using nodec

This is what I see when I try to compile my js. Why is it saying no module named nodedownload? Please help....

-> cd /tmp/nodec/node
-> Running ["./configure "]
Traceback (most recent call last):
  File "./configure", line 38, in <module>
    import nodedownload
ImportError: No module named nodedownload
Failed running ["./configure "]

Ubuntu 16.10 x86_64 not ok 320 parallel/test-fs-access

not ok 320 parallel/test-fs-access
# 
# assert.js:85
#   throw new assert.AssertionError({
#   ^
# AssertionError: Got unwanted exception..
#     at _throws (assert.js:350:5)
#     at Function.doesNotThrow (assert.js:369:3)
#     at Object.<anonymous> (/root/enclose-io-compiler/vendor/node-v7.0.0/test/parallel/test-fs-access.js:105:8)
#     at Module._compile (module.js:638:32)
#     at Object.Module._extensions..js (module.js:647:10)
#     at Module.load (module.js:555:32)
#     at tryModuleLoad (module.js:508:12)
#     at Function.Module._load (module.js:500:3)
#     at Module.runMain (module.js:672:10)
#     at run (bootstrap_node.js:389:7)
  ---
  duration_ms: 0.111
  ...

Cannot complete the process on Linux

I am running on a 4 core and 4 GB ram machine, but not able to complete the process.

virtual memory exhausted: Cannot allocate memory
deps/libsquash/enclose_io_libsquash.target.mk:95: recipe for target '/tmp/nodec/node/out/Release/obj.target/enclose_io_libsquash/deps/libsquash/sample/enclose_io_memfs.o' failed
make[1]: *** [/tmp/nodec/node/out/Release/obj.target/enclose_io_libsquash/deps/libsquash/sample/enclose_io_memfs.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/tmp/nodec/node/out'
Makefile:75: recipe for target 'node' failed
make: *** [node] Error 2
Failed running ["make -j4"]

Support for library only projects?

Good day,

I was wondering if you are planning to add support for "library only" modules and let them be included using the bindings modules or similar ones.

This would a pretty cool feature for anyone who is planning to deploy his library without any direct executable code.

What are you thoughts?

need a friendly way to remind user to install mksquashfs

C:\nodejs\Application>nodec bin\www.js -r C:\nodejs\Application -d c:\nodejs\tmp
Node.js Compiler (nodec) v0.9.3 (runtime 7.5.0)

Entrance: C:/nodejs/Application/bin/www.js
Options: {:root=>"C:\\nodejs\\Application", :tmpdir=>"c:/nodejs/tmp", :npm=>"npm", :make_args=>"-j4", :vcbuild_args=>"nosign", :output=>"C:/nodejs/Application/a.exe"}

-> mkdir -p c:/nodejs/tmp
-> cp -r "C:/__enclose_io_memfs__/_local_/node" "c:/nodejs/tmp/node"
-> rm -rf c:/nodejs/tmp/__work_dir__
-> mkdir -p c:/nodejs/tmp/__work_dir__
-> cp -r "C:/nodejs/Application" "c:/nodejs/tmp/__work_dir__/__enclose_io_memfs__"
-> cd c:/nodejs/tmp/__work_dir__/__enclose_io_memfs__
-> Running ["\"npm\" -v"]
2.14.4
-> Running ["\"npm\" install"]
-> cd C:/nodejs/Application
-> cd c:/nodejs/tmp/__work_dir__/__enclose_io_memfs__
-> cd C:/nodejs/Application
-> cd c:/nodejs/tmp/node
-> rm -f deps/libsquash/sample/enclose_io_memfs.squashfs
-> rm -f deps/libsquash/sample/enclose_io_memfs.c
-> Running ["mksquashfs -version"]
C:/__enclose_io_memfs__/_local_/lib/compiler/utils.rb:26:in `spawn': No such file or directory - mksquashfs -version (Errno::ENOENT)
        from C:/__enclose_io_memfs__/_local_/lib/compiler/utils.rb:26:in `run'
        from C:/__enclose_io_memfs__/_local_/lib/compiler.rb:155:in `block in make_enclose_io_memfs'
        from C:/__enclose_io_memfs__/_local_/lib/compiler/utils.rb:33:in `block in chdir'
        from C:/__enclose_io_memfs__/_local_/lib/compiler/utils.rb:33:in `chdir'
        from C:/__enclose_io_memfs__/_local_/lib/compiler/utils.rb:33:in `chdir'
        from C:/__enclose_io_memfs__/_local_/lib/compiler.rb:152:in `make_enclose_io_memfs'
        from C:/__enclose_io_memfs__/_local_/lib/compiler.rb:113:in `run!'
        from /__enclose_io_memfs__/_local_/bin/nodec:115:in `<main>'

可以先用着这个 https://github.com/pmq20/squashfuse/files/691217/sqfs43-win32.zip

我再想想怎么提示用户装这个

Prerequisites on Windows

The installation instructions say to install both VS 2013 and VS 2017 - why both? In another issue (#43) I saw that the CI build was referenced - would following the CI commands suffice to complete the pre-reqs and then install nodec?

If so, could the installation instructions for windows on the readme be updated? Directly downloading python/ruby/squash/node/npm seems more doable and easier to pitch to my any team than having to download two version of visual studio, and then also needing to use the visual studio shell. (Can't I just use git bash or power shell?) Now, most teams interested in this actually already might have both visual studios, but maybe not. Maybe they're a custom nodejs shop and have cross platform teams working in vim / vscode / sublime / atom etc.

But idk, maybe not.

Thanks for reading <3<3 Feel free to disregard / close. If those instructions are what's needed, than that's that. Just an honest question 😃

$.02

Failed compilation - "No such file or directory @ rb_sysopen"

Hi,

I'm trying to compile my node app on MacOS v10.11.6. It fails with the following error:

-> cp "/var/folders/kz/vj4tms290qq_04ylv6p54ks40000gq/T/nodec/node/out/Release/node" "nodec_output/app"
/__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1289:in `initialize': No such file or directory @ rb_sysopen - nodec_output/app (Errno::ENOENT)
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1289:in `open'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1289:in `block in copy_file'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1288:in `open'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1288:in `copy_file'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:429:in `copy_file'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:356:in `block in cp'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1460:in `block in fu_each_src_dest'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1476:in `fu_each_src_dest0'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:1458:in `fu_each_src_dest'
	from /__enclose_io_memfs__/_global_/lib/ruby/2.4.0/fileutils.rb:355:in `cp'
	from /__enclose_io_memfs__/_local_/lib/compiler/utils.rb:39:in `cp'
	from /__enclose_io_memfs__/_local_/lib/compiler.rb:250:in `compile_mac'
	from /__enclose_io_memfs__/_local_/lib/compiler.rb:141:in `run!'
	from /__enclose_io_memfs__/_local_/bin/nodec:123:in `<main>'

I don't use ruby or rb_sysopen directly in my code, but I guess it's possible that one of the included npm modules do (although a grep in the node_modules directory for rb_sysopen drew a blank).

I am using the following version:
Node.js Compiler (nodec) v0.9.6 (runtime 7.10.0)

Can anyone help with this?

Thanks,
Giles

armhf support?

I'm running a nodejs app on an embedded device (think beaglebone black or raspberry pi). For non-trivial projects, npm install takes a significant amount of time on a live device. Instead I typically do the install from an x86 host using chroot and qemu-user-static. It seems like this would be great for simplifying app distribution for embedded targets.

I also use gcc-arm-linux-gnueabihf to cross-compile the kernel from x86 host, if it's more manageable to specify a cross-toolchain and stay within the x86 host env instead of a chroot.

FWIW I also use several native modules (serialport, bcrpypt and node-sqlite) so would possibly be impacted by #25

SquashFS Windows Install Instructions?

Hi there,

I'm not 100% sure how to install the SquashFS you link to in the prerequisites section of the readme. I get that's it's pre-compiled but where do we put the file? I have tried putting it into the PATH on my Windows Server machine but to no luck so far. Any further instruction would be helpful.

Thanks,

Steve

No such file or directory @compiler.rb

after running nodec .\app\app.js --output=output/app I was encountering the following error:

-> cd D:/inetpub/wwwbasis/MyMemo
-> cd C:/Users/Admin/AppData/Local/Temp/nodec/work_dir/enclose_io_memfs
D:/enclose_io_memfs/local/lib/compiler.rb:173:in ``': No such file or directory - git status (Errno::ENOENT)
from D:/enclose_io_memfs/local/lib/compiler.rb:173:in block in npm_install' from D:/__enclose_io_memfs__/_local_/lib/compiler/utils.rb:33:in block in chdir'
from D:/enclose_io_memfs/local/lib/compiler/utils.rb:33:in `chdir'
from D:/enclose_io_memfs/local/lib/compiler/utils.rb:33:in `chdir'
from D:/enclose_io_memfs/local/lib/compiler.rb:171:in `npm_install'
from D:/enclose_io_memfs/local/lib/compiler.rb:141:in `run!'
from /enclose_io_memfs/local/bin/nodec:143:in `

'
PS D:\inetpub\wwwbasis\MyMemo>

Used nodec version: 1.0.0

can you tell me what that means or how to fix it?

Cannot complete the process on Linux

env

  • centos: 6.8 (Final)
  • SquashFS Tools 4.3
  • gcc and g++ 4.8.2
  • clang 3.4.2
  • Python 2.6 or 2.7
  • GNU Make 3.81
  • node 8.1.3

just compile console.log("hello world")

nodec --skip-npm-install -r . index.js

error info

/tmp/ccRY1e7x.s: Assembler messages:
/tmp/ccRY1e7x.s:1073: Error: expecting string instruction after `rep'
make[1]: *** [/tmp/nodec/node/out/Release/obj.target/icuucx/deps/icu-small/source/common/utrie2.o] 错误 1
make[1]: *** 正在等待未完成的任务....
/tmp/cccpM5jy.s: Assembler messages:
/tmp/cccpM5jy.s:570: Error: expecting string instruction after `rep'
make[1]: *** [/tmp/nodec/node/out/Release/obj.target/v8_libbase/deps/v8/src/base/utils/random-number-generator.o] 错误 1
/tmp/ccy5Jq5E.s: Assembler messages:
/tmp/ccy5Jq5E.s:3292: Error: expecting string instruction after `rep'
make[1]: *** [/tmp/nodec/node/out/Release/obj.target/icuucx/deps/icu-small/source/common/putil.o] 错误 1
make[1]: Leaving directory `/tmp/nodec/node/out'
make: *** [node] 错误 2
Failed running ["make -j4"]

Example code is not working

Hello,

I tried to use node-compiler but I failed to run example code

git clone --depth 1 https://github.com/eggjs/examples.git
cd examples/helloworld
npm install
nodec node_modules/.bin/egg-bin
./a.out dev (or a.exe dev on Windows)

npm install was fine but nodec node_modules/.bin/egg-bin emit error like below
Cannot find entrance C:/Users/kangcs.SOLID/myTest/examples/node_modules/.bin/egg-bin.

Thank you!

Additional Questions

  1. Can you give more details how to use node-compiler?
  2. I want to make my hapi server to binary file for distribution. In this situation, is the ENTRANCE for nodec app.js ?

Support for linked modules?

Hello,

I wonder if there are plans to support linked packages for this project?
It would be pretty cool if I could npm link my_other_cool_package and then compile it all together.

But when I try that, the program crashes at the point of the require - making links not usable.
Please let me know if you desire a sample "not-working-project" project.

Best regards

Failed running ["call vcbuild.bat x64"]

Hi,
When compiling my codes, I get an error as follows:
-> Running ["call vcbuild.bat x64"]
'vcbuild.bat' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
Failed running ["call vcbuild.bat x64"]

I looks like this error is related with Visual Studio. Well, I do have vs2015 update 3, but don't install vs2017. Should I install vs2017 to fix this problem? Any ideas?
Many thanks.

(IMPORTANT) avoid TMPDIR going stale

See .#25

Also, have you cleaned your temporary directory that the compiler uses? If old directory generated by nodec 0.x is used then it would be problematic. I should fix this this in a precautionary way.

9 issues and thoughts; show diff made to the node source code

Dear @pmq20, Thank you so much for the great work. I tested your Node compiler and it's outstanding. But I have some issues and thoughts to share with you.

1- I don't know much about C++ compiling, but it seems Node Compiler compiles all the C files each time and the whole build process takes so long even on a high-end machine. Is it possible to cache intermediate C++ objects before linking to reduce upcoming build time?

2- I did some testing with fs.readFile and fs.writeFile, it seems they work on the actual filesystem and it's a good idea. But the interesting thing is stylus package which generates CSS file from STYL file and stores them in assets folder doesn't work on the file system (no assets folder is created in the directory) although an empty enclose_io_memfs folder is created (which is unnecessary and probably a bug) where executable is deployed. So my question is how can read and write be done on ram partition instead of the filesystem?

3- Be able to use a custom icon and file description for the executable output. maybe an icon file in the package root directory.

4- Have predefined node command arguments like NODE_ENV=production and besides the ability to exclude files it's possible to use compiled CSS from Stylus and compiled PUG instead of plain ones. It's also a good idea to omit devDependencies packages in the package.json file.

5- I don't know if it's possible to have the app run in the background for example as a Windows service. It's a good option.

6- It's nice to be able to exclude unnecessary node built-in modules to decrease build time, output size and complexity.

7- I use closure compiler to transpile my js file to another folder, It's nice to be able to map the compiled folder to the source one during compile time. This way source is excluded and compiled takes its place.

8- I think defining options like output, tmpdir, auto-update-url and others in package.json is better than the command line as they persist in the package. maybe this format:
{..., nodec:{output:'', icon:'', description:'', args: 'NODE_ENV=production', service: true, exclude: {files: [], modules: []}, map: [{src: './jsc', dst: './js'}], ...}, ...}

9- I read the docs but didn't find anything if Node Compiler uses the V8 Compiler feature to compile JS codes for better code protection and performance. It seems enclosejs use this feature. https://github.com/v8/v8/blob/master/src/compiler.cc

Thank you for your time

detect simultaneous runs of nodec

Hi,

If you create the smallest script using the https://github.com/scottgonzalez/node-wordpress library to post a post to a WordPress site, it will not compile. It dies with this message:

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [/private/var/folders/7m/t5j9b17x4n9gkml89tck1s4c0000gn/T/nodec/node/out/Release/mksnapshot] Error 1
rm de7168347652b3d5f6d7374947b15853a841ec81.intermediate
make: *** [node] Error 2
Failed running ["make -j4"]

I've done a few other scripts that are just as small and they compile fine. But, add this library and call it it will not compile. The script runs fine using node, but if you browserify it, it no longer works. I bet that points to an issue with the library?

BTW: It took around an hour to try to compile it. That library must be very complicated.

Are Native modules supported.

Thank you for this amazing compiler.

I tried to compile one of my project which is using microtime native module. I compiled it succesfully, but when I run binary I get following error:

/__enclose_io_memfs__/node_modules/node-time-uuid/node_modules/microtime/node_modules/bindings/bindings.js:83
        throw e
        ^

Error: /__enclose_io_memfs__/node_modules/node-time-uuid/node_modules/microtime/build/Release/microtime.node: cannot open shared object file: No such file or directory
    at Object.Module._extensions..node (module.js:598:18)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at bindings (/__enclose_io_memfs__/node_modules/node-time-uuid/node_modules/microtime/node_modules/bindings/bindings.js:76:44)
    at Object.<anonymous> (/__enclose_io_memfs__/node_modules/node-time-uuid/node_modules/microtime/index.js:1:96)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/__enclose_io_memfs__/node_modules/node-time-uuid/lib/objectid.js:22:17)

So my question is. Are native modules supported?

error while loading shared libraries

Downloaded the latest version 1.1.0 on Ubuntu 14.04
When running the command I get below error

./nodec: error while loading shared libraries: libreadline.so.5: cannot open shared object file: No such file or directory

执行时,内部模块加载pacage.json出错

fs.js:583
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/__enclose_io_memfs__/node_modules/muri/lib/../package.json'
    at Object.fs.openSync (fs.js:583:18)
    at Object.fs.readFileSync (fs.js:490:33)
    at Object.<anonymous> (/__enclose_io_memfs__/node_modules/muri/lib/index.js:240:17)

node_modules/muri/lib/index.js:240:17

/**
 * Version
 */

module.exports.version = JSON.parse(
  require('fs').readFileSync(__dirname + '/../package.json', 'utf8')
).version;

Error during compilation...

Hi,
On a different machine, when I try to compile,I get this error...

make[1]: *** [/tmp/nodec/node-v8.1.4/out/Release/obj.target/enclose_io_libsquash/deps/libsquash/sample/enclose_io_memfs.
o] Error 1
rm 2bd47e96d6715d427749a9aecb9fbbcb47a76f14.intermediate
Makefile:76: recipe for target 'node' failed
make: *** [node] Error 2
Failed running ["make -j4"]

Please help..

Thanks.

/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found

I know, this is a problem of shared lib.

I compiled my app on a gentoo box with glibc-2.23. Then put it on a CentOS 7 box with glibc-2.17.

  • gentoo box: run compiled app perfectly.
  • centos 7: Bang with following information:

jet is my app.

./jet: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by ./jet)
./jet: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by ./jet)

Do not know how to solve this problem. Can you help to solve it? What kind of information should I provide for you ?

"It should match the enclosed Node.js runtime version of the compiler."

Just tried this out using the example provided by the CLI, and got this output:

Node.js Compiler (nodec) v0.9.5 (runtime 7.7.3)

It should match the enclosed Node.js runtime version of the compiler.
Expecting v7.7.3; yet got v7.8.0.

Obviously, my local version of node is 7.8.0. Does this mean I need to downgrade to 7.7.3 to use this tool? If so, this is not mentioned anywhere in the README.

windows 10 Pro x64: 6 test failures

not ok 54 parallel/test-child-process-double-pipe
# events.js:160
#       throw er; // Unhandled 'error' event
#       ^
#
# Error: spawn grep ENOENT
#     at exports._errnoException (util.js:1026:11)
#     at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
#     at onErrorNT (internal/child_process.js:359:16)
#     at _combinedTickCallback (internal/process/next_tick.js:74:11)
#     at process._tickCallback (internal/process/next_tick.js:98:9)
#     at Module.runMain (module.js:674:11)
#     at run (bootstrap_node.js:389:7)
#     at startup (bootstrap_node.js:144:9)
#     at bootstrap_node.js:530:3
  ---
  duration_ms: 0.177
  ...

Raspbian compile

Hi,

First thank you for your awesome job.
I need to compile my node app for raspberry pi. The compiled sources don't work on raspbian.
I've tried to clone the repo and launch the compiler directly from bin/nodec. That works until the ".configure" part. See the picture.
nodec

Any idea?

Build a cli app in Windows 10 Enterprise x64

Hi,
I'm trying to compile a cli application, but it is failing with the following message:

capture

I'm using the following ruby version: ruby 2.4.0p0 (2016-12-24 revision 57164) [i386-mswin32_140]
Can you help me?

Thanks!

Windows Max_Path limitation

Hello,

I just encountered the dreaded windows 260-character path length limitation. while trying to compile a relatively simple application that uses the Knex.js database abstraction library.

I know this is not a node-compiler problem, but was wondering if you had any workaround.
I've made some research and it appears everyone is blaming each other with this issue (Node.js, NPM, Microsoft, etc..)

Best regards,

Stephen..

how to get the right application working directory, not /__enclose_io_memfs__/

I compiled my node project with nodec-x64.exe v1.2.0 on windows 10, everything works fine except that when I use 'path.normalize(__dirname + '/..')' it turns out to be like 'C:\enclose_io_memfs...' instead of my real application directory(c:\Users\frank\github\myapp).
I tried to specify the root using 'nodec.exe --root=./ server.js ', results the same.
so how can I get the right working directory.

Document auto-update

I think we should write down a small example describing the usage of auto-update inside our README.md since only exposing the flags may not be trivial to new users.

@pmq20 may it be possible to better clarify how often it will check the specified URI for updates and maybe make it settable?

Use `bin` attribute from package.json instead of `main` (if given)

Hey @pmq20, thanks for this tool.
The compilation works great on smaller projects and cli tools so far.
Got some issues though with path resolving for assets within the executable,
in a more complex project, will have a deeper look these days and see how it goes.

One thing I noticed was that the compiler uses the main attribute in the package.json,
which specifies the lib entry point, while bin specifies the executable/cli entry point.
Would be great to have bin override main if given, if that makes sense for others as well.

EDIT: Thinking about it again, that's not what the bin attribute is for. Mhh... how to mix lib and executable entry points?

Failed running mksquashfs

Failed running mksquashfs:

C:\git\Observer\Node\ObsNode>C:\nodec\nodec-x64.exe --clean-tmpdir app.js
Node.js Compiler (nodec) v1.0.0 (runtime 8.0.0)

Entrance: C:/git/Observer/Node/ObsNode/app.js
Options: {:clean_tmpdir=>true, :npm=>"npm", :make_args=>"-j4", :vcbuild_args=>"x64", :output=>"C:/git/Observer/Node/ObsNode/a.exe", :tmpdir=>"C:/Users/gre63396/AppData/Local/Temp/nodec"}

-> rm -rf C:/Users/gre63396/AppData/Local/Temp/nodec
-> mkdir -p C:/Users/gre63396/AppData/Local/Temp/nodec
-> cp -r "C:/__enclose_io_memfs__/_local_/node" "C:/Users/gre63396/AppData/Local/Temp/nodec/node"
-> rm -rf C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__
-> mkdir -p C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__
-> cp -r "C:/git/Observer/Node/ObsNode" "C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__/__enclose_io_memfs__"
-> cd C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__/__enclose_io_memfs__
-> Running ["\"npm\" -v"]
4.6.1
-> Running ["\"npm\" install --production"]
-> cd C:/git/Observer/Node/ObsNode
-> cd C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__/__enclose_io_memfs__
-> cd C:/git/Observer/Node/ObsNode
-> cd C:/Users/gre63396/AppData/Local/Temp/nodec/node
-> rm -f deps/libsquash/sample/enclose_io_memfs.squashfs
-> rm -f deps/libsquash/sample/enclose_io_memfs.c
-> Running ["mksquashfs -version"]
mksquashfs version 4.3 (2014/05/12)
copyright (C) 2014 Phillip Lougher <[email protected]>

[----------------------------------------------------------]
Compiled by Sebastiaan Ebeltjes @ 2015-06-08 (Domoticx.nl)
Compiled with Cygwin on Windows 8.1, compiler: GCC v4.9.2

This version comes with added support for:
- LZMA v4.65
- LZMA2 (XZ) v5.5.0
- LZO v2.09
- LZ4 r130

Enjoy!

[----------------------------------------------------------]

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2,
or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
-> Running ["mksquashfs \"C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__\" deps/libsquash/sample/enclose_io_memfs.squashfs"]
Failed running ["mksquashfs \"C:/Users/gre63396/AppData/Local/Temp/nodec/__work_dir__\" deps/libsquash/sample/enclose_io_memfs.squashfs"]

Support arbitrary node.js runtime versions

Hello,
as discussed already in other issues I think nodec should be able to compile using a user defined node version among whose supported by the applied patches.

I didn't have any chance to test the patches with the v6.x, v7.x and v8.x but since those were versions supported by nodec itself I guess we should have some sort of support for them (by the way I'd really like to add some tests against regressions).

Patches have evolved while also upgrading the supported node version, so I think we should still be able to verify the patches apply properly and that node.js retains its functionalities after those patches are applied.

My purpose is to:

  • add a --node-version=7.0.0 flag to the nodec binary (or --runtime, but I think node-version is more user-friendly) and keep the latest nodejs version (or maybe the LTS) as the default
  • alter the ruby script (compiler) to
    • download source from the original nodejs.org website (https://nodejs.org/download/release/)
    • checksum the downloaded tar file to guard against tampering or network errors since the build will be used in production
    • extract the source code
    • apply the patches to node core (by using the system diff or some ruby gem)
    • ideally, check there was no regression after patching (e.g. run the nodejs test suite)
    • compile the node project

I'd really like to avoid what other similar tools do that is to download the detected (current-system) node version: it's ugly, annoying for nvm users, error prone and furthermore in a CI/CD environment one may need to skip this (and using nvm to workaround this might get complicated as nvm is hard to be used in some shell scripts). Also I don't think there's really some logical reason one should assume that I want my local node version on my servers.

I already started to work and implemented the flag and the download part, but I'm not sure how would you like to distribute the patch: do you want to place a .patch file inside this repo?
I'd avoid to keep the expanded source code under node/ because it could lead to unwanted patching (e.g. files modified from one version to another would be modified, and we would need to declare what files to pick explicitly, which may still get unwanted modifications.

I'd like to know your thoughts about it @pmq20

Thank you.

Cross Windows Support for Native Modules?

Hey there,

So I have a quick question about running the compiled executables on different versions of Windows. I've been understanding that native modules need to be built on their target platform for a while now and the idea of compiling a Node application with native modules brings up a question to me. If I were to compile an application with native modules on Windows 7 using nodec, would that build work on Windows 10 or Windows Server 2016? I had been under the impression that it needed to be built on each platform but maybe the compiled Node app solves this?

Any help in understanding this would be appreciated, thanks.

Error when using with with uws

uws uses native add ons for websockets

"Compilation of µWebSockets has failed and there is no pre-compiled binary available for your system. Please install a supported C++11 compiler and reinstall the module 'uws'"
at native (/enclose_io_memfs/node_modules/uws/uws.js:38:19)
at Object. (/enclose_io_memfs/node_modules/uws/uws.js:42:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/enclose_io_memfs/main.js:11:23)

https://github.com/uWebSockets/uWebSockets/issues/595

compiler is out of heap space

Precondition:
Windows 7 32-bit, available 2320 MB from 3400 MB.
node v7.9.0,
mksquashfs v4.3,
Visual Studio 2015,

Example coffeescript project finished failed:
"sample\enclose_io_memfs.c(166117): fatal error C1060: compiler is out of heap space"

How long will it take to run the program?

Hi,

When I'm trying to run the examples, it took me nearly 20 minutes to run...
I followed your instructions and there weren't any mistakes. So could you tell me how long will it take on average to run this?

Thank you

fail on startserver

还是 enclose 包里面非 js 文件的问题

curl -o ss.gz http://someurl/-startserver-1.3.1-x64-darwin.gz && gunzip ss.gz && chmod +x ss && ./ss
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 9766k  100 9766k    0     0  4007k      0  0:00:02  0:00:02 --:--:-- 4009k
<<WARN>> : Get remote update info failed.
<<INFO>> : Running at http://0.0.0.0:8080
<<INFO>> : Method: GET Url: /
__enclose_io_memfs__/node_modules/startserver/node_modules/foc/lib/foc.js:45
        if (error) throw error;
                   ^

Error: ENOENT: no such file or directory, open '__enclose_io_memfs__/node_modules/startserver/lib/middleware/directory/default.tpl'
    at Error (native)

Example not run,/__enclose_io_memfs__/node_modules/.bin/egg-bin

一.by example,but not can run.

➜  tmp ./a.out dev
module.js:487
    throw err;
    ^

Error: Cannot find module '/__enclose_io_memfs__/node_modules/.bin/egg-bin'
    at Function.Module._resolveFilename (module.js:485:15)
    at Function.Module._load (module.js:437:25)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:162:16)
    at bootstrap_node.js:579:3

二.ENV:

➜  tmp uname -a
Darwin YUANYUANdeMacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Tue Apr 11 16:00:51 PDT 2017; root:xnu-3248.60.11.5.3~1/RELEASE_X86_64 x86_64
➜  tmp node -v
v8.1.1
➜  tmp npm -v
5.0.3
➜  tmp gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin15.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
➜  tmp /usr/bin/make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

thanks

Buffer size

Hi,

For an app that uses modbus and mbus communication, in a Raspberry, I have this error
RangeError: "size" argument must not be larger than 1073741823

This error is only thrown with the compiled app, not with the sources and not on a 64 bits system...

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.