turf
turf copied to clipboard
TypeError: Cannot read property 'POLYGON_CLIPPING_MAX_QUEUE_SIZE' of undefined
@turf/turf 6.5.0 webpack 5
I'm using turf in a NativeScript project, the sample code could be very simple:
import * as turf from '@turf/turf';
export class TestClass {
testFn() {
const p = turf.point([-73.988214, 40.749128]);
}
}
I tried all turf version above 5.1.6, all get the same error, but when using 5.1.6, it works well.
Thanks for the help!
Hmm it's due to something upstream in the polygon-clipping library but it's been there for ages so I'm not sure why it's a particular problem in your instance that no-one else has reported...
https://github.com/mfogel/polygon-clipping/blob/b064f942061e9820c53a462ebcccda7407330007/src/operation.js#L10-L17
Thanks @rowanwins for your quick feedback. Yeah, I understand that and cannot google much about it either. I can live with version 5.1.8 at the moment and probably will try to reproduce it in a plain empty project to get a bit more info. Thanks again!
If I was going to hazard a guess process isn't available in the NativeScript environment.
I'm using Turf with a Nuxt JS project and just started seeing this as well. It looks like the client side env isn't being defined suddenly (weird).
@cloudhx Which Native Script flavor are you using? Could a check be added for process.env !== 'undefined'?
The same would need to be done for POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS.
Possible workaround here https://github.com/nuxt/nuxt.js/issues/14276
I am able to reproduce this when I run my vue component (which imports bbox from turf) in a cypress component test, but unable to reproduce it when I run that vue component locally. Very odd.
It seems the error is gone anyway, will verify the version and code with some latest setup.
Any updates?? I have the same problem. @Ben-VP thanks for this workaround!
Edit: I update my Nuxt version and it works fine without any workarounds :)