This is a snippet of html code in a test.html
file.
<script src="monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'monaco-editor/min/vs' }});
require(['vs/editor/editor.main'], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
});
});
</script>
this is a file tree on my system.
ide
├── cpp14
│ ├── test.html
├── monaco
└── node_modules
├── monaco-editor
└── test.html
I copied test.html
file from monaco/node_moules/
to cpp14
And changed all the paths in cpp14/test.html
to
<script src="ide/monaco/node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': 'ide/monaco/node_modules/monaco-editor/min/vs' }});
require(['ide/monaco/node_modules/monaco-editor/min/vs/editor/editor.main'], function() {
var editor = monaco.editor.create(document.getElementById('container'), {
value: [
'function x() {',
'\tconsole.log("Hello world!");',
'}'
].join('\n'),
language: 'javascript'
});
});
This is not working and I think there is error in setting path of those files in the snippet. How to make this work ?
Try aliasing it: