A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://stackoverflow.com/questions/79709755/unable-to-set-json-as-language-in-monaco-editor below:

asp.net core mvc - Unable to set json as language in monaco editor

In my ASP.NET Core MVC view, I have the following code:

<script type="module"> 
import * as monaco from 'https://cdn.jsdelivr.net/npm/monaco-editor@latest/+esm'; 
document.addEventListener('DOMContentLoaded', () => { 
  monaco.editor.create(document.getElementById('editor-container'), {
    value: '{\n  "key": "value"\n}',
    language: 'json',
    theme: 'vs-dark',
    minimap: {
                enabled: false
            }
  });
});
</script>
<div id="editor-container" style="width:800px;height:600px;border:1px solid #ccc;"></div>

But, the browser console shows the following error:

standaloneLanguages.js:275 Uncaught (in promise) Error: Cannot set tokens provider for unknown language json
at Object.J7 [as setTokensProvider] (standaloneLanguages.js:275:15)
at s (jsonMode.js:2682:59)
at Module.$te (jsonMode.js:2712:3)
at monaco.contribution.js:102:33

How to fix this?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4