ReferenceError: self is not defined - prism-keep-markup
See original GitHub issueInformation:
- 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:
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:
- Created 4 years ago
- Comments:6 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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 gettingUncaught 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.@RunDevelopment Yeah, we’re pretty inconsistent on how we check what the global variable is, looking at our plugins.
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…