Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TS2307: Cannot find module 'mapbox-gl/dist/mapbox-gl.js'. #3767

Closed
michaelpwilson opened this issue Dec 8, 2016 · 3 comments
Closed

Comments

@michaelpwilson
Copy link

michaelpwilson commented Dec 8, 2016

I am getting an error when trying to import mapboxgl into my TypeScript file.

mapbox-gl-js version: 0.28.0

Steps to Trigger Behavior

  1. Import mapboxgl like in the README: import mapboxgl from 'mapbox-gl/dist/mapbox-gl.js';
  2. Run tsc
  3. An error is outputted although mapbox works fine

Expected Behavior

No error to be outputted, as mapbox does in fact work even though this error is outputted

Actual Behavior

Error is outputted although mapbox still works fine:

error TS2307: Cannot find module 'mapbox-gl/dist/mapbox-gl.js'.

@mourner
Copy link
Member

mourner commented Dec 8, 2016

If Mapbox does work even with the error, are you sure this is not a TypeScript bug?

@michaelpwilson
Copy link
Author

michaelpwilson commented Dec 8, 2016

I was able to get around this issue by using this import instead:

import * as mapboxgl from 'mapbox-gl';

But not all is fixed by this. I'm using Rollup for bundling and this has now caused an error:

Illegal reassignment to import 'mapboxgl'
Error: Illegal reassignment to import 'mapboxgl'
    at error (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\utils\error.js:2:14)
    at disallowIllegalReassignment (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\shared\disallowIllegalReassignment.js:9:4)
    at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\AssignmentExpression.js:12:3)
    at C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:34
    at Node.eachChild (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:21:5)
    at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:8)
    at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\BlockStatement.js:8:9)
    at Node.bind (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\nodes\FunctionExpression.js:7:13)
    at C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:6:34
    at Node.eachChild (C:\Users\m.wilson\AppData\Roaming\npm\node_modules\rollup\src\ast\Node.js:21:5)

@jfirebaugh
Copy link
Contributor

Using mapbox-gl/dist/mapbox-gl.js is the correct way to use Mapbox GL JS in a non-Browserify module system. If this is causing an error with TypeScript, you'll need to file a bug with that project -- I don't think there's anything we can do on our side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants