question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceError: self is not defined - prism-keep-markup

See original GitHub issue

Information:

  • Prism version: “prismjs”: “^1.19.0”
  • Plugins: .babelrc { ... ["line-numbers", "show-language", "keep-markup"]
  • Environment: [Next.js]

Does the latest version of Prism from the download page also have this issue? Yes

Description After adding "keep-markup" to the plugins list, the app fails: image

Example Reproduction available below PS you can stop the app from crashing by disabling "keep-markup" in .babelrc https://codesandbox.io/s/nextjs-prismjs-slate-u5rmz

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
mAAdhaTTahcommented, Mar 21, 2020

Ok. So removing the passing-in of self & document seems to resolve the issue locally for me. That’s the only plugin that passes in those variables, oddly enough. Will PR shortly.

That said, there are some other underlying issues uncovered by this. line-numbers does not look good, and I’m getting Uncaught Error: Cannot resolve a Slate node from DOM node: [object HTMLDivElement] errors trying to type into the Slate editor. If Slate is wrapping each line in its own DOM node, I don’t think we can guarantee that Prism will behave correctly.

0reactions
mAAdhaTTahcommented, Mar 21, 2020

@RunDevelopment Yeah, we’re pretty inconsistent on how we check what the global variable is, looking at our plugins.


That said, it looks like the error occurs not on the call, but on the Prism instance import itself

That makes sense, because that’s when self is first referenced. That said, it looks like the error is on the server-side, rather than in the browser. Or maybe it’s both? Pretty odd…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript + Webpack library generates "ReferenceError: self ...
This issue is related to the option output.globalObject of which is described here. I believe webpack has set it as self for a...
Read more >
ReferenceError: self is not defined - Blockcerts Forum
Hi all, I am running the server.js sample code for NodeJS and I get the following error:
Read more >
Server side usage of services - Maps SDK for Web (JavaScript)
ReferenceError : self is not defined. We imported the package like this import tt from '@tomtom-international/web-sdk-services';
Read more >
node-self - npm
Start using node-self in your project by running `npm i ... But, in Node.js console.log(self); // ReferenceError: self is not defined.
Read more >
ReferenceError: self is not defined - MongoDB
I'm using mongodb-stitch-browser-sdk 4.8.0. I'm simply trying to import Stitch using this code… import { Stitch } from ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found