wavded / ogr2ogr

An ogr2ogr wrapper library
MIT License
216 stars 46 forks source link

Module not found: Error: Can't resolve 'fs' - installation #104

Closed informatter closed 12 months ago

informatter commented 1 year ago

Hi everyone,

I am trying to install the ogr2ogr in a Vue 2.7.14. Initially it "successfully" installed after running npm install ogr2ogr

After adding import ogr2ogr from 'ogr2ogr' to a vue component to test the installation, my app fails to build due to the below polyfill errors:

To mitigate the issue, I added the following to webpack.config.js to ignore the polyfills for the above

    resolve:{
      fallback:{
        "os":false,
        "constants":false,
        "path":false,
        "stream":false,
        "zlib":false
      }
    }

After rebuilding the app, polyfill errors are gone as expected, but now I am seeing the following errors:

 ERROR  Failed to compile with 7 errors                                                                                                                                                                              3:44:52 PM

 error  in ./node_modules/archiver/lib/core.js

Module not found: Error: Can't resolve 'fs' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/archiver/lib'

 error  in ./node_modules/fs.realpath/index.js

Module not found: Error: Can't resolve 'fs' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/fs.realpath'

 error  in ./node_modules/glob/common.js

Module not found: Error: Can't resolve 'fs' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/glob'

 error  in ./node_modules/graceful-fs/graceful-fs.js

Module not found: Error: Can't resolve 'fs' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/graceful-fs'

 error  in ./node_modules/readdir-glob/index.js

Module not found: Error: Can't resolve 'fs' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/readdir-glob'

 error  in ./node_modules/ogr2ogr/dist/esm/index.js

Module not found: Error: Can't resolve 'child_process' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/ogr2ogr/dist/esm'

 error  in ./node_modules/ogr2ogr/dist/esm/index.js

Module not found: Error: Can't resolve 'fs' in '/Users/hammer-dev-003/Documents/HammerMissions/hub/node_modules/ogr2ogr/dist/esm'

But I am not sure why the fs is not being found?

wavded commented 1 year ago

I am not a Vue user, but it seems to be a frontend JS framework. ogr2ogr has to run on the server side to work.

ralyodio commented 12 months ago

you need to create an api endpoint that has access to your server's filesystem.

informatter commented 12 months ago

Ok cool makes sense!