Not working with nextjs?
See original GitHub issueDescribe the bug i try to use react-monaco-editor with next.js based on this tutorial. But all time i have a lot of errors:
Uncaught (in promise) Error: Unexpected usage
at EditorSimpleWorker.push../node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js.EditorSimpleWorker.loadForeignModule (editorSimpleWorker.js:540)
at webWorker.js:54
Uncaught TypeError: Failed to construct 'URL': Invalid URL
at push../node_modules/normalize-url/index.js.module.exports (index.js:46)
at getReloadUrl (hotModuleReplacement.js:74)
at hotModuleReplacement.js:92
at NodeList.forEach (<anonymous>)
at reloadStyle (hotModuleReplacement.js:89)
at update (hotModuleReplacement.js:119)
at invokeFunc (debounce.js:95)
at trailingEdge (debounce.js:144)
at timerExpired (debounce.js:132)
Uncaught (in promise) Error: Unexpected usage
at EditorSimpleWorker.push../node_modules/monaco-editor/esm/vs/editor/common/services/editorSimpleWorker.js.EditorSimpleWorker.loadForeignModule (editorSimpleWorker.js:540)
at webWorker.js:54
my code:
import React from 'react'
import PropTypes from 'prop-types'
import * as monaco from '@timkendrick/monaco-editor/dist/external'
import MonacoEditor from 'react-monaco-editor'
window.MonacoEnvironment = { baseUrl: '/monaco-editor-external' }
/**
* @param {string} code
* @returns {*}
* @constructor
*/
const CodeEditor = ({code}) => {
const options = {
selectOnLineNumbers: true
}
return (
<MonacoEditor
// width="800"
height="600"
language="javascript"
theme="vs"
// theme="vs-dark"
value={''}
options={options}
onChange={() => {}}
editorDidMount={() => {}}
/>
)
}
CodeEditor.propTypes = {
code: PropTypes.string.isRequired,
}
export default CodeEditor
in server.js added:
...
server.use(
'/monaco-editor-external',
express.static(`${__dirname}/node_modules/@timkendrick/monaco-editor/dist/external`)
)
...
To Reproduce install “react-monaco-editor”: “^0.34.0” “monaco-editor”: “^0.20.0” “monaco-editor-webpack-plugin”: “^1.9.0” “@timkendrick/monaco-editor”: “0.0.9” “next”: “^9.2.1” “react”: “^16.12.0”
Expected behavior work without errors
Environment (please complete the following information):
- OS: mac
- Browser chrome
- Bundler webpack
guys, please, help me. I spent for that a lot of time, i tried use with/without MonacoWebpackPlugin
, with/without @stoplight/monaco, but i still got error 😦
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:27
Top Results From Across the Web
javascript - Tailwindcss not working with next.js; what is wrong ...
Considering that there's no such issue opened at Tailwind, I guess the problem has something to do with Next.js not purging properly.
Read more >TailwindCSS not working in NX NextJS project. #8355 - GitHub
Current Behavior Following the egghead tutorial for a NextJS project with a new nx-workspace, installing Tailwind is not working.
Read more >Debugging Tailwind CSS and Next.js - LogRocket Blog
Common issues with Tailwind CSS and Next.js · Not having the Tailwind directives in the main CSS file · Not assigning the CSS...
Read more >module-not-found - Next.js
The module you're trying to import uses Node.js specific modules, for example dns , outside of getStaticProps / getStaticPaths / getServerSideProps. Possible ...
Read more >How to Set Up Next.js With Tailwind - Jake Prins
You can save yourself some time by using Next.js, a React framework that provides a solution to all of these problems above. If...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
Top Related Hashnode Post
No results found
@subwaymatch thx, you saved my day!
@monaco-editor/react just works out of the box, no need to mess up with next.js config
The following is what worked for me.
package.json
some typescript file
example usage