Giter Club home page Giter Club logo

Comments (5)

DenisCarriere avatar DenisCarriere commented on June 3, 2024

2nd observation, I couldn't get your browserify bundle to work with NodeJS, normally those Browserify bundles work for both Browser & NodeJS.

Might be something to consider looking into.

$ node
> require('./skmeans')
ReferenceError: window is not defined
    at Object.__dirname.1../main.js (/Users/mac/Github/turf/packages/turf-clusters-kmeans/skmeans2.js:21:6)
    at s (/Users/mac/Github/turf/packages/turf-clusters-kmeans/skmeans2.js:8:44)
    at e (/Users/mac/Github/turf/packages/turf-clusters-kmeans/skmeans2.js:13:3)
    at Object.<anonymous> (/Users/mac/Github/turf/packages/turf-clusters-kmeans/skmeans2.js:15:3)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)

from skmeans.

solzimer avatar solzimer commented on June 3, 2024

Hi @DenisCarriere,

Normally I only use grunt/browserify to export the module to browser only (as a 'window' global variable), because I assume that node users will only use the "require()". But I will take a look into the issue, providing a more standarized module, with window and require modes for ES5

from skmeans.

DenisCarriere avatar DenisCarriere commented on June 3, 2024

Thanks for looking into this.

Seems like you are using an outdated browserify library or some configurations are hardcoded for only browser.

I've been able to use this Browserify bundle and it works with Node, so it's not Browserify the issue.

https://wzrd.in/standalone/skmeans@latest

Also ES5 is not only for Browser support, NodeJS 4 doesn't support all the newest fancy gadgets that ES6 has to offer.

from skmeans.

solzimer avatar solzimer commented on June 3, 2024

Hi @DenisCarriere, I've updated the module to include both, an only browser module, and a ES5 version for Node.

Now, package.json points to the ES5 distribution, so it will work on older node versions, allowing you also to correctly browserify your project.

Current version is 0.9.7, also published in npm

from skmeans.

DenisCarriere avatar DenisCarriere commented on June 3, 2024

👍 Perfect! Thanks @solzimer

FYI: I've locked the version to 0.9.7, but if you ever release a major release or a critical patch, just send a PR to TurfJS or @ me.

from skmeans.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.