flowhub / guv

Autoscaling for Heroku/AMQP
https://guvscale.com
MIT License
25 stars 6 forks source link

Cannot import module if not using CoffeeScript #223

Closed timlesallen closed 6 years ago

timlesallen commented 6 years ago

Hi @jonnor.

Thanks for accepting my PRs!

Just trying to get off my fork and use guv@0.3.0. I think there is a problem with the published package. If I look in the package.json there is no main key, which means it will use index.js at the root level. This then points to src/*.coffee which of course cannot run in node.js. Missing a compile step?

Thanks!

jonnor commented 6 years ago

There was never a compile step in, we load CoffeeScript at runtime. But it looks like the module loader registration is only done in the bin scripts, not in index.js so it does not work for API usage from non-CoffeeScript. This line should be moved in there https://github.com/flowhub/guv/blob/master/bin/guv#L2

jonnor commented 6 years ago

@timlesallen Should be fixed in guv 0.3.1, just released on NPM. Verification would be much appreciated. Thanks for reporting!

ovidiusabou commented 6 years ago
$ node node_modules/.bin/guv
module.js:515
    throw err;
    ^

Error: Cannot find module '../schema/roleconfig.json'
    at Function.Module._resolveFilename (module.js:513:15)
    at Function.Module._load (module.js:463:25)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/guv/src/config.coffee:13:15)
    at Object.<anonymous> (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/guv/src/config.coffee:5:1)
    at Module._compile (module.js:612:30)
    at Object.loadFile (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
    at Module.load (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/guv/src/main.coffee:7:10)
    at Object.<anonymous> (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/guv/src/main.coffee:5:1)
    at Module._compile (module.js:612:30)
    at Object.loadFile (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/coffee-script/lib/coffee-script/register.js:16:19)
    at Module.load (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/guv/index.js:4:9)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Module.require (module.js:556:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/ovidiusabou/Projects/SectorLabs/explorer-guv/node_modules/guv/bin/guv:2:7)
    at Module._compile (module.js:612:30)
    at Object.Module._extensions..js (module.js:623:10)
    at Module.load (module.js:531:32)
    at tryModuleLoad (module.js:494:12)
    at Function.Module._load (module.js:486:3)
    at Function.Module.runMain (module.js:653:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

there seems to be no schema/roleconfig.json only a schemata/roleconfig.json

jonnor commented 6 years ago

@ovidiusabou should be fixed in guv 0.3.2 - some files where missing from NPM package when deploying via Travis CI. Thanks for reporting. In the future, please open a new issue for new things.