简体   繁体   English

摩纳哥编辑依赖性问题

[英]Monaco Editor Dependencies Issue

Whenever I launch Monaco Editor (with node.js), it comes up and seems to behave okay, but I get an error message telling me that there are missing dependencies and to check the list. 每当我启动Monaco Editor(与node.js一起使用)时,它就会出现并表现良好,但是我收到一条错误消息,告诉我缺少依赖项并检查列表。 I can't seem to find the dependency list ( I installed via NPM), but I definitely know node.js fs module is included. 我似乎找不到依赖项列表(我是通过NPM安装的),但我绝对知道其中包含了node.js fs模块。

Error Message: 错误信息:

Uncaught Error: Check dependency list! Synchronous require cannot resolve module 'fs'. This is the first mention of this module!
at s.synchronousRequire (loader.js:27)
at s (loader.js:34)
at /Library/Application Support/rack/node_modules/monaco-edit…:7
at /Library/Application Support/rack/node_modules/monaco-edit…:7
at ts (/Library/Application Support/rack/node_modules/monaco-edit…:7)
at /Library/Application Support/rack/node_modules/monaco-edit…:7
at t._loadAndEvalScript (loader.js:20)
at loader.js:19
at tryToString (VM1651 fs.js:449)
at FSReqWrap.readFileAfterClose [as oncomplete] (VM1651 fs.js:436)

Usage: 用法:

    <script src="node_modules/monaco-editor/min/vs/loader.js"></script>
<script>
require.config({ paths: { 'vs': __dirname + '/node_modules/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>

Anyone else run into this issue? 还有其他人遇到这个问题吗? Thanks! 谢谢!

Looks like the getNodeSystem() function in vs/language/typescript/typescriptServices.js tries to require the base Node modules, but if you already have them required then it will return an error. 看起来像vs / language / typescript / typescriptServices.js中的getNodeSystem()函数尝试要求基本的Node模块,但是如果您已经需要基本的Node模块,那么它将返回错误。

Kind of a hacky solution, but works for now is to replace their definitions with the already defined versions. 有点不可靠的解决方案,但是现在可以用已经定义的版本替换它们的定义。 If someone has a better fix, let me know. 如果有人有更好的解决方案,请告诉我。 cc @estus 抄送@estus

function getNodeSystem() {
            // var _fs = require("fs");
            // var _path = require("path");
            // var _os = require("os");
            var _fs = fs;
            var _path = path;
            var _os = os; 
            [...]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM