ngageoint / geopackage-js

GeoPackage JavaScript Library
http://ngageoint.github.io/geopackage-js/
MIT License
304 stars 78 forks source link

TypeError: GeoPackageAPI.open is not a function #173

Closed jfoclpf closed 3 years ago

jfoclpf commented 3 years ago

When I simply run in nodejs 14.16.1 and after npm install @ngageoint/geopackage

const GeoPackageAPI = require('@ngageoint/geopackage')

GeoPackageAPI.open(path.join('res', 'Cont_AAD_CAOP2020.gpkg'), function(err, geoPackage) {
  console.log(geoPackage)
})

I get this error

Better SQLite
/home/joao/dev/geo-pt-api/index.js:48
GeoPackageAPI.open(path.join('res', 'Cont_AAD_CAOP2020.gpkg'), function(err, geoPackage) {
              ^

TypeError: GeoPackageAPI.open is not a function
danielbarela commented 3 years ago

It looks like our documentation is out of date. The correct code should be (note the require change):

const GeoPackageAPI = require('@ngageoint/geopackage').GeoPackageAPI

GeoPackageAPI.open(path.join('res', 'Cont_AAD_CAOP2020.gpkg'), function(err, geoPackage) {
  console.log(geoPackage)
})
jfoclpf commented 3 years ago

Thanks, then I would suggest you to update documentation ;)

newmanw commented 3 years ago

@jfoclpf PRs are always welcome.