【问题标题】:how to install officegen module in node webkit如何在 node webkit 中安装 officegen 模块
【发布时间】:2014-10-06 11:53:35
【问题描述】:

好吧,我是 node webkit 的新手,谁能帮我解决以下问题?

我想在 node webkit 可执行包中使用“officegen”插件,但不适合我。请参阅下面的代码。

我在这个 JS 所在的位置有 officegen 文件夹。

var officegen = require('officegen/lib/index.js'); 

错误消息:错误:找不到模块'officegen/lib/index.js'

【问题讨论】:

    标签: node.js node-webkit


    【解决方案1】:

    要引用相同的路径,请在前面加上./,否则将解析为当前目录或父目录中的node_modules

    var officegen = require('./officegen/lib/index.js'); 
    

    http://nodejs.org/api/modules.html#modules_file_modules

    【讨论】:

    • 我试过了,但仍然出现同样的错误。错误:找不到模块'./officegen/lib/index.js'
    • @pratiknagariya 您确定 officegen 的路径与您在其中调用 require 的文件是相对的吗?不是您的应用程序根目录?
    • 是的,文件路径是相对于写入 'require' 的文件的路径。
    • 嗯,应该可以,不过可能跟node-webkit有关,见github.com/rogerwang/node-webkit/wiki/…
    • 最简单的解决方案应该是 npm install officegenrequire('officegen')
    猜你喜欢
    • 2016-04-30
    • 1970-01-01
    • 2023-03-28
    • 1970-01-01
    • 2020-07-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多