简体   繁体   中英

Can't run node module geojson-polygon-labels on Windows

I've download the package from " https://github.com/andrewharvey/geojson-polygon-labels/ ", ran "npm-install" and the node-modules folder was successfully created: folder - screenshot

However, when cd to bin folder and run "geojson-polygon-labels < v.geojson > v_label.geojson", it throws the eror: "not recognized as internal or external command, operable program or batch file".

I'm really confused at this point. On github it's not really well-documented how to use this tool, and I'm quite new to Node too.

Please help me. Thanks!

Edit: I've tried install it on Ubuntu (subsystem on Windows 10) then run "geojson-polygon-labels" from the bin folder. The same error occured.

Edit2: I figured out to how properly run the tool. On Ubuntu I ran:

./geojson-polygon-labels < polygon.geojson > labels.geojson

However, now a new error pops out:

/home/lamnguyen/geojson-polygon-labels-master/bin/geojson-polygon-labels:25
turf.featureEach(flatInputGeoJSON, (feature) => {
                                              ^
SyntaxError: Unexpected token >
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:902:3

What should I do now?

Edit 4: A friend of mine ran it on a "real" Ubuntu with a small sample file and it worked out. Maybe tomorrow I've give a shot :)

In this package I've set up the bin property in the package.json https://docs.npmjs.com/files/package.json#bin so when you run npm install it knows what scripts are executables. You might need to set up your PATH in your shell to the directory NPM installs the binaries to. Or use the full or relative path as you've found out.

The Unexpected Token > message seems like you're running an older version of node which doesn't support ES6 arrow functions, so try upgrading your version of node?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM