Node throws error (Unexpected number) on compilation #61

rricard opened this Issue Aug 9, 2012 · 0 comments


None yet
2 participants

rricard commented Aug 9, 2012

Hi !
It's been a few hours I'm fighting with the r.js compilation (note : that works on heroku, but other errors are thrown anyway !).
Every time I'm trying to compile ... I get this (with --trace argument) :

** Invoke assets:precompile (first_time)
** Invoke requirejs:precompile:external (first_time)
** Invoke requirejs:test_node (first_time)
** Execute requirejs:test_node
** Execute requirejs:precompile:external
/usr/local/Cellar/rbenv/0.3.0/versions/1.9.3-p194/bin/ruby /usr/local/Cellar/rbenv/0.3.0/versions/1.9.3-p194/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke requirejs:precompile:all (first_time)
** Invoke requirejs:precompile:prepare_source (first_time)
** Invoke requirejs:setup (first_time)
** Invoke assets:environment (first_time)
** Invoke requirejs:precompile:disable_js_compressor (first_time)
** Execute requirejs:precompile:disable_js_compressor
** Execute assets:environment
** Execute requirejs:setup
** Invoke requirejs:clean (first_time)
** Invoke requirejs:setup 
** Execute requirejs:clean
** Execute requirejs:precompile:prepare_source
** Invoke requirejs:precompile:generate_rjs_driver (first_time)
** Invoke requirejs:setup 
** Execute requirejs:precompile:generate_rjs_driver
** Invoke requirejs:precompile:run_rjs (first_time)
** Invoke requirejs:setup 
** Invoke requirejs:test_node (first_time)
** Execute requirejs:test_node
** Execute requirejs:precompile:run_rjs


  var compiledWrapper = runInThisContext(wrapper, filename, true);
SyntaxError: Unexpected number
    at Module._compile (module.js:437:25)
    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:315:13)
rake aborted!
Asset compilation with node failed.

I tried with three different node versions (0.6.21, 0.8.4 and 0.9.0). I don't think it comes from my code (for the moment, it's just as simple as the samples) but from somewhere else I don't know (maybe node considering that I'm using the n version manager).
I tried to use the r.js command directly but it does not play nice with the rails directory structure.
If you have any idea or help to give me : first, to debug this (I'm ok with pure ruby or pure node debugging but this ...) and if you have more time, to locate and patch with me (if it's a bug) this error.

Anyway, thank you for the awesome plugin !
I'll continue to investigate ... !

EDIT : I think I found it by following the node stack trace ! I added in the rake task in your gem a line which is supposed to print the temporary rjs driver :

print `cat #{requirejs.config.driver_path}`

And ... surprise ! the path to the driver is incomplete ! I had a space in one of my parent directories that wasn't escaped well ! I'll give you a patch soon !

jwhitley closed this in 8a437fe Aug 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment