mapbox / mapbox-gl-directions

Directions plugin for mapbox-gl-js using Mapbox Directions API.
https://mapbox.com/mapbox-gl-js/example/mapbox-gl-directions/
ISC License
237 stars 123 forks source link

Error: Can't resolve 'fs' #185

Open tsaldanha opened 6 years ago

tsaldanha commented 6 years ago

I have a problem with my webpack/react system and I am trying to run the mapbox-gl with mapbox-gl-directions, but I am stuck with this error with the 'fs' that is a dependency of this projects.

ERROR in ./node_modules/@mapbox/mapbox-gl-directions/src/controls/inputs.js Module not found: Error: Can't resolve 'fs' in '/home/tadeu/Projects/lisbon-cycle/node_modules/@mapbox/mapbox-gl-directions/src/controls' @ ./node_modules/@mapbox/mapbox-gl-directions/src/controls/inputs.js 6:9-22 @ ./node_modules/@mapbox/mapbox-gl-directions/src/directions.js @ ./node_modules/@mapbox/mapbox-gl-directions/src/index.js @ ./src/Map/index.js @ ./src/index.js @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/index.js

abe732 commented 6 years ago

Having the same problem, did you find a solution?

tsaldanha commented 6 years ago

@abe732 , I make a like direct to the dist/ folder of mabox directions, isnt ideal, but It worked.

yulivee commented 6 years ago

for working with angular5, importing this module like this does the trick: import * as MapboxDirections from '@mapbox/mapbox-gl-directions/dist/mapbox-gl-directions';

cafca commented 3 years ago

Not working anymore in current version

jcardus commented 2 years ago

I'm having the same problem...

jcardus commented 2 years ago

I solved it using the javascript externally. I'm using nuxt, had to change the externals configuration in webpack.

giovanniincammicia commented 2 years ago

I'm having the same problem, I can't even start the application. Do the maintainers even reply?

The file that uses fs is: https://github.com/mapbox/mapbox-gl-directions/blob/master/src/controls/inputs.js

austin-InDro commented 1 year ago

Still not working as of Dec 21st 2022

Tordx commented 1 year ago

Feb 2023, still not working

Osama-02 commented 1 year ago

not working

soury commented 1 year ago

May 2023, still not working

janfigala commented 1 year ago

for working with angular5, importing this module like this does the trick: import * as MapboxDirections from '@mapbox/mapbox-gl-directions/dist/mapbox-gl-directions';

This workaround appears to be working for me for the same issue but with Next.js. Thanks @yulivee!

AndrewTsytsarkin commented 1 year ago

need to export Mapbox_directions like this: const MapboxDirections = require('@mapbox/mapbox-gl-directions/dist/mapbox-gl-directions');

Check out: https://github.com/AndrewTsytsarkin/MapboxDirectionsTypescript