【问题标题】:Deployment of Node native modules to Azure WebSites,I'm experiencing some problems将 Node 本机模块部署到 Azure 网站,我遇到了一些问题
【发布时间】:2017-04-26 05:31:14
【问题描述】:
  • 我将节点应用程序部署到 Azure 网站。
  • 棘手的部分是我正在使用一个名为“opencv”的节点模块,需要在安装时使用 node-gyp 进行编译。
  • 我使用node-gyp rebuild --arch=ia32命令将它编译到windows10.但是当我在 Azure 网站上使用它时,我遇到了以下问题:
Wed Apr 26 2017 04:48:35 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:

Error: The specified module could not be found.

\\?\D:\home\site\wwwroot\app\api\lib\opencv.node

at Error (native)
at Object.Module._extensions..node (module.js:434:18)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (D:\home\site\wwwroot\app\api\lib\image_operation.js:5:14)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)

这是我调用的代码:

'use strict';
var fs = require('fs');
var path = require('path');
var opencv = require("./opencv.node");

function isContains(str, substr) {
    return new RegExp(substr).test(str);
}

module.exports = {
    post: function (imageInfo, data) {
        if (isContains(imageInfo.imageName, ".yuv")) {
            var imageName = imageInfo.imageName.substr(0, imageInfo.imageName.length - 3) + "jpg";
            opencv.yuvToJpeg(path.resolve(__dirname, "../../image/" + imageName), imageInfo.width, imageInfo.height, Array.prototype.slice.call(data, 0));
        } else if (isContains(imageInfo.imageName, ".jpg")) {
            fs.writeFileSync(path.resolve(__dirname, "../../image/" + imageInfo.imageName), data);
    }
            return "success";
    }
};

但该文件实际上已部署在服务器上:

请帮帮我,告诉我该怎么做

【问题讨论】:

    标签: node.js azure opencv azure-web-app-service node-modules


    【解决方案1】:

    readme 表示 “在安装 node-opencv 之前,您需要安装 OpenCV 2.3.1 或更新版本”。由于 Azure Web Apps 是一种软件即服务 (SaaS),我们无权在其中安装任意软件。但如果这是您的要求,您将需要使用替代产品,例如云服务或虚拟机。

    【讨论】:

      猜你喜欢
      • 2014-09-28
      • 2018-08-21
      • 1970-01-01
      • 2015-11-20
      • 2020-08-21
      • 1970-01-01
      • 2021-01-20
      • 2022-01-25
      • 2022-11-23
      相关资源
      最近更新 更多