Brackets.io扩展中存在模块不存在错误

Module does not exist error in Brackets.io extension

本文关键字:模块 不存在 错误 存在 io 扩展 Brackets      更新时间:2023-09-26

我正在为Brackets.io编辑器开发一个扩展。我想加载trie-search,一个npm模块。

cd转到扩展的本地目录,然后运行:

npm install trie-search

扩展代码必须如下所示:

define(function (require, exports, module) {
    "use strict";
    var AppInit           = brackets.getModule("utils/AppInit"),
        CodeHintManager     = brackets.getModule("editor/CodeHintManager"),
        LanguageManager     = brackets.getModule("language/LanguageManager" ),
        TrieSearch          = require('trie-search'), // throws an error
        MGfuncHint          = require('text!mg-func.txt');

这会抛出一个错误,称为module does not exist。如何加载模块?

U可能想要尝试以下操作。

var TrieSearch = new NodeDomain("simple", ExtensionUtils.getModulePath(module, "trie-search"));

参考链接:https://github.com/adobe/brackets/wiki/Brackets-Node-Process:-开发者概述#使用示例

希望它能帮助

干杯