layerssss / turfjs-ruby

Turf.js bridge for ruby
1 stars 0 forks source link

SyntaxError when doing simple operation #5

Open ghost opened 3 years ago

ghost commented 3 years ago

I get a SyntaxError with this code:

TurfJS.point([1, 2])

Output:

ExecJS::RuntimeError (SyntaxError: Unexpected token =):

(execjs):1:70
...

Any idea why this is happening here?

layerssss commented 3 years ago

The published gem has webpack-ed/babel-ed turfjs targetting node@8. I think the error was caused by your underlying execjs backend is an older version of node.js (assuming it's node.js). If that's the case, possibly there are 2 workarrounds:

  1. upgrade your nodejs to >=8
  2. recompile the javascript in the gem, while changing this to your node.js version.

https://github.com/layerssss/turfjs-ruby/blob/master/webpack.config.js#L22

Anyway, can't imagine you've figure it out without any docs.

ghost commented 3 years ago

@layerssss thanks for the information. I should normally be using node 14, so I don't think that's the problem. I will get back to you when I have more information.

layerssss commented 3 years ago

@henri-cowboy then it might be because the execjs is using other backends instead of node.js? If you have one of the gems here https://github.com/rails/execjs