node-packer icon indicating copy to clipboard operation
node-packer copied to clipboard

Example code is not working

Open kangchals opened this issue 8 years ago • 8 comments

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 ?

kangchals avatar Jul 07 '17 07:07 kangchals

It very is nice to check the issue very quickly. Good. I want to give more information on the environment. The OS is windows10 and I follow the installing step carefully. Thank you~

kangchals avatar Jul 07 '17 09:07 kangchals

@kangchals I think the problem is that you have cd'ed into C:/Users/kangcs.SOLID/myTest/examples instead of C:/Users/kangcs.SOLID/myTest/examples/helloworld.

I have not used hapi.js before but a glance onto the document shows that you should probably set the ENTRANCE to be server.js as in the example of https://hapijs.com/

pmq20 avatar Jul 08 '17 03:07 pmq20

@kangchals Please let me know if it works now, thanks

pmq20 avatar Jul 08 '17 03:07 pmq20

Sorry, my mistake...

Now, nodec node_modules/.bin/egg-bin works fine after I add global path for sqfs43-win32.

The result of nodec is a.exe, However, it is not working.

After executing a.exe, the error message is showing like below.

C:\Users\kangcs.SOLID\myTest\examples\helloworld>a.exe
C:\__enclose_io_memfs__\node_modules\.bin\egg-bin:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:74:10)
    at Object.runInThisContext (vm.js:116:10)
    at Module._compile (module.js:533:28)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:162:16)
    at bootstrap_node.js:579:3

kangchals avatar Jul 10 '17 02:07 kangchals

@kangchals Sorry for the delay. I'll look into this ASAP.

pmq20 avatar Jul 20 '17 11:07 pmq20

@kangchals It turns out that the entrance is not a valid JavaScript file. node_modules/.bin/egg-bin and node_modules/.bin/egg-bin.cmd are actually shell scripts and batch programs (or symbolic links in some cases) that all point to node_modules/egg-bin/bin/egg-bin.js.

Running it with the real entrance fixes the problem, i.e. nodec node_modules/egg-bin/bin/egg-bin.js.

pmq20 avatar Jul 26 '17 03:07 pmq20

It's working as per 845b547f71e0c83d6becc21bdbbdae39c152ce23

image

pmq20 avatar Jul 26 '17 05:07 pmq20

@pmq20 I don't think a.out can work without source code. What if you try this:

mv ./a.out ~/temp/

And then go to temp run again:

cd ~/temp/
./a.out dev

It will get this error:

⚠️  AssertionError [ERR_ASSERTION]: /Users/yourname/temp/package.json should exist
⚠️  Command Error, enable `DEBUG=common-bin` for detail

See also this

wind13 avatar Aug 10 '18 09:08 wind13