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 when requiring mapbox-gl-js in Node #8442

Closed
ahk opened this issue Jul 8, 2019 · 6 comments
Closed

Error when requiring mapbox-gl-js in Node #8442

ahk opened this issue Jul 8, 2019 · 6 comments

Comments

@ahk
Copy link
Contributor

ahk commented Jul 8, 2019

when I import mapbox-gl 12.x by nodejs (V=12.x) that gives me a error which is " nodejsReferenceError: self is not defined.What can I do the next can help me.thanks

Originally posted by @lf1991 in #8424 (comment)

Hi @lf1991, I started a new thread for your issue (I don't think you were having an issue with benchmarks on Firefox). You are using nodejs 12.x with the newest mapbox-gl-js correct? If you are using mapbox-gl and having an issue this might not be the correct project.

I can tell you that mapbox-gl-js (this project) doesn't support nodejs higher than 10.x, so if you try with nodejs 8 or 10 that may solve your issue.

@mourner
Copy link
Member

mourner commented Jul 8, 2019

Older nodes will still have a problem: #4593

@mourner mourner changed the title Nodejs version support question Error when requiring mapbox-gl-js in Node Jul 8, 2019
@bradjonesca
Copy link

It sure would be nice to see some testing for Nodejs 12 soon ;)

@ahk
Copy link
Contributor Author

ahk commented Jul 9, 2019

Older nodes will still have a problem: #4593

Sorry I misunderstood what @lf1991 was trying to do, thanks @mourner. This was informative.

@samkelleher
Copy link

I don't believe this is a Node issue, as far as I can tell, this libary doesn't work in Node at all. The error above is because the library is executing on import and trying to access browser specific APIs.

I.e., this code should not do any execution. The library has side effects, meaning it is executing and trying to access browser specific APIs.

import mapbox from "mapbox-gl";

See #4593 (comment)

@aendra-rininsland
Copy link
Contributor

This is effectively a duplicate of #4593 — the issue isn't a Node version issue, it's an "eagerly accesses browser globals on module import" issue.

My suggestion is to close this issue and reopen #4593 where there's been a fair bit more discussion recently.

@mourner
Copy link
Member

mourner commented Sep 13, 2019

@Aendrew good call — reopened #4593, closing this issue in favor of that one.

@mourner mourner closed this as completed Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants