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

ReferenceError: Prism is not defined #3154

Open
britt6612 opened this issue Oct 12, 2021 · 9 comments
Open

ReferenceError: Prism is not defined #3154

britt6612 opened this issue Oct 12, 2021 · 9 comments

Comments

@britt6612
Copy link

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.

@RunDevelopment
Copy link
Member

@mAAdhaTTah

@mAAdhaTTah
Copy link
Member

Can you provide a reproducible test case?

@mAAdhaTTah
Copy link
Member

mAAdhaTTah commented Oct 12, 2021

Also, I'm going to transfer this issue to the babel plugin repo. Edit: No I'm not, it's not owned by the org lol

@britt6612
Copy link
Author

I can see if I can try to reproduce a test case in JSFiddle,
This error just occurred in our team project.

@britt6612
Copy link
Author

This looks a little similar
mAAdhaTTah/babel-plugin-prismjs#194

@mAAdhaTTah
Copy link
Member

Did you remove the .next folder and retry? I haven't gotten a reproducible case for that either.

@britt6612
Copy link
Author

yes I also tried to remove the .next folder and then building the project again I got the same error when running yarn build

@ivangsp
Copy link

ivangsp commented Jun 14, 2023

I'm having similar error after installing it on Next app (v13.22.4). The error occurs when I import any of the prismjs components ie import "prismjs/components/prism-javascript". I'm using version 1.29

@amira-maouch
Copy link

amira-maouch commented Jan 12, 2024

I encountered the same error and the problem was in imports organization only, we previously had :
import 'prismjs/components/prism-clike';
import { highlight, languages } from 'prismjs/components/prism-core';
import 'prismjs/components/prism-http';

but the prism-core should be imported first so it was solved by changing it to:
import { highlight, languages } from 'prismjs/components/prism-core';
import 'prismjs/components/prism-clike';
import 'prismjs/components/prism-http';

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

5 participants