igorklopov / enclose

Compile your Node.js project into an executable
http://enclosejs.com
Other
936 stars 43 forks source link

Coffee script support #98

Closed loretoparisi closed 7 years ago

loretoparisi commented 8 years ago

I have a project with Coffee script, I get several errors when trying to compile

$ enclose --loglevel info -x -o my-app-x64-mac ./index.js 

/my-app/node_modules/coffee-script/lib/coffee-script/grammar.js
  info  Cannot find module 'jison' from '/my-app/node_modules/coffee-script/lib/coffee-script'

Any way to resolve those dependencies?

loretoparisi commented 8 years ago

[UPDATE] It seems to be a problem with node_modules actually:

Supposed to have a library like

lib/
  index.js // <--- exports  = requiire('module1/main.js')
  module1/
      main.js //<--- import ('some_module')
node_modules/
    some_module/
       index.js
package.json

If I try to run

$ enclose --loglevel info -x -o mylib-node-x64-mac ./lib/index.js

it seems it does not resolve project node modules dependencies.

igorklopov commented 8 years ago

Does compiler emit any warning? Are you talking about jison in your second post? grammar.js seems to be unused for casual cases. Either jison. How do you manage to require grammar.js? What version of coffee-script do you have?

loretoparisi commented 8 years ago

@igorklopov it seems it is not related to coffee-script but to node_module dependencies, look at the example, basically it refuses to load the first module dependency in the chain like:

/my-node-lib/node_modules/cheerio/index.js
  error  Cannot find module './lib-cov/cheerio' from '/my-node-lib/node_modules/cheerio'

that is referenced from some file in my lib/index.js main file dependencies. Of course I have installed all dependencies in node_modules I mean I run a npm install beforehand.

loretoparisi commented 8 years ago

[UPDATE] So basically I have two kind of issues, but it seems to be the same at the end. For the electron / coffee script app it is the following:

So I can see that executable:

macbookproloreto:my-app admin$ file my-app-x64-mac 
my-app-x64-mac: Mach-O 64-bit executable x86_64

but if I try to run it I get the modules errors:

Error: Cannot find module 'electron'
1) If you want to enclose the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to enclose the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.argv[1].
  at Module._resolveFilename (module.js:325:15)
  at Function.Module._load (module.js:276:25)
  at Module.require (module.js:353:17)
  at require (internal/module.js:12:17)

while for the library it is the previous one.

igorklopov commented 7 years ago

Dear users of EncloseJS! I highly encourage you to switch to https://github.com/zeit/pkg It is rewritten successor of EncloseJS. It is open source, and all improvements will go there. Please check if pkg has your issue unresolved, and if it is true, reopen your issue there: https://github.com/zeit/pkg/issues