PrismJS / PrismJS/prism

ReferenceError: Prism is not defined

Open
#3,154 9 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13k
Forks
1.4k
Avg merge
15h 36m
Merged PRs (30d)
3

Description

Information:

  • Prism version: [latest version 1.25.0 ]
  • Plugins: [babel-plugin-prismjs 2.1.0]
  • Environment: [next.js]

Description
After upgrading from version 1.24.0 to 1.25.0 I found that when trying to run the project I was receiving the error that
ReferenceError: Prism is not defined

    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at eval (webpack-internal:///prismjs/components/prism-clike:1:18)
    at Object.prismjs/components/prism-clike

I got the following error above.

My babel is set up as such

{
    "presets": ["next/babel"],
    "plugins": [
        ["styled-components", { "ssr": true }],
        ["prismjs", {
            "languages": ["javascript", "css", "html", "jsx"],
            "css": false
        }]
    ]
}

Example
An example which reproduces the bug. This can be a link to a website, a JSFiddle, an attached example project, etc.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the startup failure with Prism 1.25.0, Next.js, and the shown Babel configuration. Start from the prismjs/components/prism-clike stack entry and compare behavior with Prism 1.24.0; done means the example project starts without ReferenceError: Prism is not defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, next.js
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.