PrismJS / prism

Lightweight, robust, elegant syntax highlighting.
https://prismjs.com
MIT License
12.21k stars 1.29k forks source link

ReferenceError: Prism is not defined #3154

Open britt6612 opened 2 years ago

britt6612 commented 2 years ago

Information:

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 commented 2 years ago

@mAAdhaTTah

mAAdhaTTah commented 2 years ago

Can you provide a reproducible test case?

mAAdhaTTah commented 2 years ago

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 commented 2 years ago

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

britt6612 commented 2 years ago

This looks a little similar https://github.com/mAAdhaTTah/babel-plugin-prismjs/issues/194

mAAdhaTTah commented 2 years ago

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

britt6612 commented 2 years ago

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 commented 1 year ago

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 commented 7 months ago

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';