-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks. #216
Comments
@jaywcjlove Hopefully you can check it for me . Error happend in this file : https://github.com/uiwjs/react-codemirror/blob/master/src/useCodeMirror.ts#L80 |
I see the error message, not the error caused by |
@jaywcjlove sorry I have send wrong picture. I have updated this |
@jaywcjlove Can you check again |
I have check your code in IDE and something wrong like this @jaywcjlove |
@jaywcjlove I have down grade uiw/code-mirror to version 3.2.7 and it is ok to run but something like color or code-mirror extension is not use. Hopefully when you update your live you can notice me to update new version. |
I have same problem. Did you solve this? @jaywcjlove @dungbv99 |
|
@jaywcjlove @NguyenTruongThanh-74 I have know this problem, when i run yarn add @uiw/react-codemirror --save or npm install @uiw/react-codemirror --save now it will install 1 node module in this package @uiw/react-codemirror so the duplicate is happened |
I have the same problem. |
@dungbv99 upgrade |
@abc444873863 @NguyenTruongThanh-74 Seems to be a dependency problem. upgrade |
@jaywcjlove okay let me try it |
@jaywcjlove I have check new version, The error is remove but the line number is disable. |
@abc444873863 you can run |
npm ls @codemirror/view
[email protected] /Users/wangchujiang/git-project/@uiw/demo/react-code-mirror-error
├─┬ @codemirror/[email protected]
│ ├─┬ @codemirror/[email protected]
│ │ ├─┬ @codemirror/[email protected]
│ │ │ └── @codemirror/[email protected] deduped
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ ├─┬ @codemirror/[email protected]
│ │ │ └── @codemirror/[email protected] deduped
│ │ ├─┬ @codemirror/[email protected]
│ │ │ └── @codemirror/[email protected] deduped
│ │ └── @codemirror/[email protected] deduped
│ └── @codemirror/[email protected]
└─┬ @uiw/[email protected]
├─┬ @codemirror/[email protected]
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ ├─┬ @codemirror/[email protected]
│ │ └── @codemirror/[email protected] deduped
│ └── @codemirror/[email protected] deduped
├─┬ @codemirror/[email protected]
│ └── @codemirror/[email protected] deduped
└── @codemirror/[email protected]
@dungbv99 This is a problem caused by version locking. |
We fixed this in our application by adding a Yarn Resolution to force a single version of
{
"resolutions": {
"@codemirror/highlight": "0.19.7",
"@codemirror/lang-javascript": "0.19.7",
"@codemirror/state": "0.19.9",
"@codemirror/view": "0.19.47"
}
} |
I was having the same problem due to @codemirror/stream-parser being archived. now StreamParser must be imported from @codemirror/language @jaywcjlove please update the readme. |
@shubhendusaurabh Welcome to submit PR |
I get it too with latest version. Actually even my current version which is deployed and working does not work on my laptop. Removing node_modules and package.lock.json do nothing. |
In my case with webpack + typescript changing |
You are my hero man, only this stuff helps... thank you ! |
I am getting the same error but while testing my CodeEditor component with Vitest. Any suggestions? |
I am also seeing this issue with https://github.com/SpaceCowboy326/react-codemirror-vitest Just run |
Using commonjs was causing issues with react-codemirror. See codemirror/dev#528 and uiwjs/react-codemirror#216
I'm also seeing this issue with |
For posterity, this is the solution that worked for me. My problem specifically was that |
Just playing around with a very basic hello world via URL imports, and ran into this problem. Downgrading <script type="module">
import {EditorState} from "https://cdn.jsdelivr.net/npm/@codemirror/[email protected]/+esm";
import {EditorView, keymap} from "https://cdn.jsdelivr.net/npm/@codemirror/[email protected]/+esm";
// upgrading this to `6.1.2` causes this: "Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks"
import { oneDark } from "https://cdn.jsdelivr.net/npm/@codemirror/[email protected]/+esm";
let startState = EditorState.create({
doc: "Hello World",
extensions: [
oneDark,
],
});
let view = new EditorView({
state: startState,
parent: document.body,
});
</script> (if URL imports like this aren't generally supported, then that's just tragic imo - makes it hard to play around with e.g. codepen/jsbin, create little demos, etc.) |
Building on my comment above, if you are also using {
"resolutions": {
"**/@mischnic/json-sourcemap/@lezer/common": "0.15.12",
"**/@mischnic/json-sourcemap/@lezer/lr": "0.15.8",
"**/@codemirror/autocomplete/@lezer/common": "1.1.0",
"**/@codemirror/commands/@lezer/common": "1.1.0",
"**/@codemirror/lang-javascript/@lezer/common": "1.1.0",
"**/@codemirror/language/@lezer/common": "1.1.0",
"**/@codemirror/language/@lezer/lr": "1.3.11"
}
} Otherwise, the automatic dependency version upgrades from the bots will cause CodeMirror to break - eg. by losing syntax highlighting. |
any one using pnpm and next.js following solution worked for me
|
Hi, Error: Unrecognized extension value in extension set ([object Object]). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks Is there any real fix for this issue? |
@RajkiranJogu Were you able to solve it? Got the same issue ;/ |
React 18 + Webpack 5. Very basic setup. The webpack alias trick was the only thing that worked for me.
|
I was able to solve it using
Basically, you need to force the CJS version of |
Ultimately, If you are using vite as project build tool, you should use these configuration, // vite.config.js
import { defineConfig } from 'vite';
import path from "path";
export default defineConfig({
optimizeDeps: {
include: ['@codemirror/state', '@codemirror/view'],
},
resolve: {
alias: {
'@codemirror/state': path.resolve(
__dirname,
'./node_modules/@codemirror/state/dist/index.cjs'
),
'@codemirror/lang-yaml': path.resolve(
__dirname,
),
'@codemirror/lang-json': path.resolve(
__dirname,
'./node_modules/@codemirror/lang-json/dist/index.cjs'
)
}
},
}) // package.json
{
"name": "js-vite-cm-demo",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"devDependencies": {
"vite": "^5.2.0"
},
"dependencies": {
"@codemirror/basic-setup": "^0.20.0",
"@codemirror/lang-javascript": "^6.2.2",
"@codemirror/state": "^6.4.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@codemirror/view": "^6.26.3",
"codemirror": "^6.0.1"
}
} |
Using commonjs was causing issues with react-codemirror. See codemirror/dev#528 and uiwjs/react-codemirror#216
Using commonjs was causing issues with react-codemirror. See codemirror/dev#528 and uiwjs/react-codemirror#216
If anyone is still having a problem, try this: vite.config.ts export default defineConfig(async () => ({
resolve: {
alias: {
'@codemirror/state': path.resolve(__dirname, 'node_modules/@codemirror/state/dist/index.cjs'),
}
}
})); |
See #613 (comment) and #680 (comment) for a proposed proper fix. |
I have a project using uiw/react-codemirror version 4.0.6
It is run okay until mid night yesterday, when I clone my project and re install it. When it start some thing wrong is happended like this picture
I think some bug happend when you update new version confile with the codemirror dependency. Can you check for me?
Thank you!
The text was updated successfully, but these errors were encountered: