uiwjs / react-codemirror

CodeMirror 6 component for React. @codemirror https://uiwjs.github.io/react-codemirror/
https://uiwjs.github.io/react-codemirror/
MIT License
1.65k stars 132 forks source link

error - TypeError: Cannot redefine property: EditorView #304

Closed mbui0327 closed 2 years ago

mbui0327 commented 2 years ago

Hi all, I run into this issue after doing npm i with version 4.7.0. It works fine with 4.6.0 Thanks.

error - TypeError: Cannot redefine property: EditorView
    at Function.defineProperty (<anonymous>)
    at ../node_modules/@uiw/react-codemirror/cjs/index.js:57:10
    at Array.forEach (<anonymous>)
    at Object.<anonymous> (/Users/bachbui/works/cycai/tmp/cyc-next/cyc-next-app/node_modules/@uiw/react-codemirror/cjs/index.js:53:26)
    at Module._compile (node:internal/modules/cjs/loader:1099:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18) {
  page: '/'
}
jaywcjlove commented 2 years ago

@mbui0327

Please provide a reproduction example via codesandbox.io.

eeve commented 2 years ago

类似的错误

ERROR in ./node_modules/@uiw/react-codemirror/esm/index.js 8:0-40
The requested module '@codemirror/basic-setup' contains conflicting star exports for the name 'EditorView' with the previous requested module '@codemirror/view'
 @ ./node_modules/xx/dist/esm/index.js 12:0-47 1182:18-28
 @ ./src/pages/xx/List.tsx 8:0-39 38:6-15 230:10-19
 @ ./src/pages/ lazy ^\.\/.*$ namespace object ./xx/List.tsx ./xx/List
 @ ./src/index.tsx 10:22-47

ERROR in ./node_modules/@uiw/react-codemirror/esm/index.js 9:0-34
The requested module '@codemirror/state' contains conflicting star exports for the name 'EditorState' with the previous requested module '@codemirror/basic-setup'
 @ ./node_modules/xx/dist/esm/index.js 12:0-47 1182:18-28
 @ ./src/pages/xx/List.tsx 8:0-39 38:6-15 230:10-19
 @ ./src/pages/ lazy ^\.\/.*$ namespace object ./xx/List.tsx ./xx/List
 @ ./src/index.tsx 10:22-47

原因也是 版本从4.6.0到4.7.0升级导致的。

jaywcjlove commented 2 years ago

@eeve 删除 node_modulespackage-lock.json 文件重新安装。

jaywcjlove commented 2 years ago

@eeve @mbui0327 Example: https://codesandbox.io/embed/react-codemirror-example-codemirror-6-slvju?fontsize=14&hidenavigation=1&theme=dark

jaywcjlove commented 2 years ago
npm ls @codemirror/basic-setup
@uiw/react-codemirror@4.7.0 /react-codemirror
└── @codemirror/basic-setup@0.20.0
npm ls @codemirror/state
@uiw/react-codemirror@4.7.0 /react-codemirror
├─┬ @codemirror/basic-setup@0.20.0
│ ├─┬ @codemirror/autocomplete@0.20.0
│ │ └── @codemirror/state@0.20.0 deduped
│ ├─┬ @codemirror/commands@0.20.0
│ │ └── @codemirror/state@0.20.0 deduped
│ ├─┬ @codemirror/language@0.20.0
│ │ └── @codemirror/state@0.20.0 deduped
│ ├─┬ @codemirror/lint@0.20.1
│ │ └── @codemirror/state@0.20.0 deduped
│ ├─┬ @codemirror/search@0.20.1
│ │ └── @codemirror/state@0.20.0 deduped
│ └── @codemirror/state@0.20.0 deduped
├─┬ @codemirror/lang-html@0.20.0
│ ├─┬ @codemirror/lang-css@0.20.0
│ │ └── @codemirror/state@0.20.0 deduped
jaywcjlove commented 2 years ago

Similar question: