![](/img/trans.png)
[英]Strange Unresolved dependencies to 'vscode' when wrapping monaco-editor and monaco-languageclient as a react component
[英]Monaco Editor Dependencies Issue
每當我啟動Monaco Editor(與node.js一起使用)時,它就會出現並表現良好,但是我收到一條錯誤消息,告訴我缺少依賴項並檢查列表。 我似乎找不到依賴項列表(我是通過NPM安裝的),但我絕對知道其中包含了node.js fs模塊。
錯誤信息:
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)
用法:
<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>
還有其他人遇到這個問題嗎? 謝謝!
看起來像vs / language / typescript / typescriptServices.js中的getNodeSystem()函數嘗試要求基本的Node模塊,但是如果您已經需要基本的Node模塊,那么它將返回錯誤。
有點不可靠的解決方案,但是現在可以用已經定義的版本替換它們的定義。 如果有人有更好的解決方案,請告訴我。 抄送@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.