账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    native modules该怎么理解?
    52
    0
    问题描述今天在学习Vue-cli-plugin-electron时,发现Native modules,直译过来为:本地模块 或者 原生模块,但是不是很理解准确的意思,是不是npm install下载下来的modules都可以认为是Native modules?补充描述以下是官方文档:Native modules are supported and should work without any configuration, assuming nodeIntegration is enabled. If you get errors, you may need to set the native dependency as an webpack external (opens new window). It should get found automatically, but it might not. To do this, use the externals option:// vue.config.jsmodule.exports = { pluginOptions: { electronBuilder: { // List native deps here if they don't work externals: ['my-native-dep'], // If you are using Yarn Workspaces, you may have multiple node_modules folders // List them all here so that VCP Electron Builder can find them nodeModulesPath: ['../../node_modules', './node_modules'] } }}
    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 软killer 普通会员 1楼

      native modules 是 Node.js 中的一种特有模块类型,它们是由 Node.js 的核心模块(如 requirefspath 等)直接导出的模块。

      在 Node.js 中,模块可以分为两类:内联模块(如 module.exports)和非内联模块(如 fspath 等)。内联模块直接被引入到代码中,而非内联模块则需要通过其他方式引入,如 require()import() 等。

      native modules 就是 Node.js 中内联模块的一种,它们通常由 Node.js 的核心模块导出,并且可以在其他 Node.js 程序中直接使用。native modules 在 Node.js 中非常常见,它们是 Node.js 程序中实现模块化编程的基础。

      native modules 的优点是方便快捷,可以直接使用,而不需要在每个模块中引入外部模块。但是,它们也有一些缺点,如模块名称与全局变量冲突、模块名称与全局函数冲突等。

      总的来说,native modules 是 Node.js 中一种重要的模块类型,它们对于 Node.js 程序的模块化编程非常有用。

    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部