Module Not Found Error

Hi all,

When I try typing the following, an error comes up:

import ‘codemirror/lib/codemirror.css’

import ‘codemirror/theme/material.css’

import ‘codemirror/mode/xml/xml’

import ‘codemirror/mode/javascript/javascript’

import ‘codemirror/mode/css/css’

This is what the error says:

ERROR in ./src/components/Editor.js 6:0-39

Module not found: Error: Package path ./lib/codemirror.css is not exported from package /Users/user/code-editor/node_modules/codemirror (see exports field in /Users/user/code-editor/node_modules/codemirror/package.json)

ERROR in ./src/components/Editor.js 7:0-39

Module not found: Error: Package path ./theme/material.css is not exported from package /Users/user/code-editor/node_modules/codemirror (see exports field in /Users/user/code-editor/node_modules/codemirror/package.json)

ERROR in ./src/components/Editor.js 8:0-33

Module not found: Error: Package path ./mode/xml/xml is not exported from package /Users/user/code-editor/node_modules/codemirror (see exports field in /Users/user/code-editor/node_modules/codemirror/package.json)

ERROR in ./src/components/Editor.js 9:0-47

Module not found: Error: Package path ./mode/javascript/javascript is not exported from package /Users/user/code-editor/node_modules/codemirror (see exports field in /Users/user/code-editor/node_modules/codemirror/package.json)

ERROR in ./src/components/Editor.js 10:0-33

Module not found: Error: Package path ./mode/css/css is not exported from package /Users/user/code-editor/node_modules/codemirror (see exports field in /Users/user/code-editor/node_modules/codemirror/package.json)

Can someone help?

This sounds like the package you’re using has an exports field in its package.json. But the one distributed with CodeMirror 5 does not, so that’s odd. How did you install the codemirror directory?

I just did the following:

First, I tried:
npm i codemirror react-codemirror2

Then, I tried:
npm i codemirror react-codemirror2-react-17

Neither worked.

I also have the same issue and have explored so many options but nothing works for me, if any one here who can solve this problem please help

same is here… please @marijn help to get rid out of this

If you are trying to install CodeMirror version 5, you should use the command

npm i codemirror@version5

because react-codemirror-2 only supports "codemirror": "5.x".

Also you can try @codemirror-toolkit/react, which supports version 6 and React above v16.8.0.

still not working bro