WebStorm自动导入-“需要”而不是“从...导入”

Guy*_*Guy 6 node.js webstorm

Alt + Enter当我的Node.js不支持import语句时,在Node.js项目上工作时,我得到建议()使用ES6进行导入。我可以添加需要使用的建议吗?自动导入可节省大量时间...

自动导入

handlerName方法定义:

const manipulateName = (layout, method) => {
    layout.name = method(layout.name);
    return layout;
}
Run Code Online (Sandbox Code Playgroud)

还有...

module.exports = {
    manipulateName,
 ...
}
Run Code Online (Sandbox Code Playgroud)

len*_*ena 11

请确保为您的项目启用Node.js 核心库(首选项 | 语言和框架 | Node.js 和 NPM,Node.js 核心库)。

请参阅缺少 require() 语句检查 ( Preferences | Editor | InspectionsJavaScript | Node.js ) 说明:

Checks that all modules are referenced through "require()".
Suggests inserting the "require()" call.
Works only in files in the scope of "Node.js Core" JavaScript library.
Run Code Online (Sandbox Code Playgroud)

  • 请查看答案 - 它是 Node.js 核心库。在最新版本中,它被称为 **Node.js 的编码帮助** 并且(仍然)可以在 **Preferences | 中启用。语言和框架 | Node.js 和 NPM** (2认同)