Comments (10)
Well, at least I got my Windows test environment set up ;)
I also published another version without the following lines, which I thought might have been responsible for the problem:
mapshaper/src/commands/mapshaper-require.mjs
Lines 23 to 25 in 578879a
(mapshaper was converting relative paths to absolute paths, because require()
didn't work correctly with some relative paths).
import()
seems to work correctly with various forms of relative paths, so it's no longer necessary to convert to absolute paths.
from mapshaper.
I'm glad you were able to find something positive in it.
But I would prefer to close the issue in shame 😄
from mapshaper.
I've just noticed that even with an valid absolute path to my script I get really strange errors:
with the script poly.mjs
export const polygon = function () {
return {
type: "FeatureCollection",
features: [{
type: "Feature",
geometry: { type: "Point", coordinates: [125.6, 10.1] },
properties: { name: "Dinagat Islands" }
}]
}
}
mapshaper `
-rectangle bbox="-180,-90,180,90" `
-require "file:///C:/myProj/poly.mjs" `
-run "target.geojson = polygon()"
Error: [i] File not found (target.geojson)
mapshaper `
-rectangle bbox="-180,-90,180,90" `
-require "file:///C:/myProj/poly.mjs" `
-run "polygon()"
Error: [i] File not found (polygon())
from mapshaper.
Thanks for reporting this... the problem was evidently caused by my switching from require()
to import()
. This was in order to support ES modules in addition to Node modules. The new code worked fine on my Mac, but I see that import()
fails on Windows using absolute paths, and according to the Node docs import()
is not supposed to work with absolute paths. This issue clarifies things: nodejs/node#31710
I'll work on a fix asap.
from mapshaper.
I published the fix given in the above-linked issue (using pathToFileURL() to convert absolute paths to file URLs). Please let me know if you still get errors -- I don't currently have a way to test on Windows.
from mapshaper.
I've just tested 0.6.58
but had no luck with relative paths:
mapshaper -require "./myScript.js"
[require] Unable to load external module: Cannot find module 'C:\Users\...\AppData\Roaming\nvm\v18.17.1\node_modules\mapshaper\myScript.js' ...
It now looks in the installation folder of the global mapshaper installation...
from mapshaper.
Hmm.. I'm going to install Parallels so I can run Windows and test this properly... if that fails I might go back to using require()
from mapshaper.
I haven't been able to reproduce the Unable to load external module
error yet... I tested with mapshaper 0.6.58
on Windows 11 (running in Parallels) using both Node 18 and Node 20 in cmd.exe
. -require
works in 0.6.58
and throws the error you first reported in 0.6.57
. Here's a screengrab:
Do you have any ideas that might help me reproduce your error? Are you using a different shell than cmd.exe
?
from mapshaper.
-require
works in powershell too, in my current setup:
from mapshaper.
🤦♂️ I'm so sorry wasting your time on this. My paths changed after I moved the scripts around.
I only realized after I tested it on a different laptop. So I guess only the initial error was valid.
Again - Sorry.
from mapshaper.
Related Issues (20)
- light blue paths and performance HOT 3
- Memory usage almost 4x size of input geojson file HOT 4
- Filter lines still create polygons HOT 5
- When hovering mouse over feature and scrolling, fill color freaks out HOT 1
- Point layers and data layers do not show up HOT 2
- Cannot convert between WGS84 and Webmercator after converting and saving data as EPSG:3857. HOT 3
- Error on simplifying GeoJSON file HOT 11
- Javascript error related to polygon editing causes GUI to crash HOT 1
- There is an issue when you import a shapefile HOT 2
- Clip command removes Features visually but not from exported file. HOT 4
- Sticky hand HOT 1
- snap effects multiples layers HOT 1
- geojson from points HOT 2
- Export failed Export failed for an unknown reason HOT 3
- topojson files in power bi HOT 2
- Problem in drawing polygon and importing snapshot file HOT 4
- Export to Shape File Not working HOT 12
- Bug: can't open snapshot file I created on mapshaper.org HOT 3
- Bug: copy as GeoJSON doesn't copy GeoJSON HOT 1
- filter-slivers remove-empty bug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapshaper.