Windows 下 nodejs 连接 oracle 配置编译连接 成功的方法

开发是采用Mac环境,部署服务器是Windows 08,中间卡壳好久。以下是windoes发布编译方法和注意点。

1:下载 Visual Studio 2013 的  C/C++ 运行环境

首先根据oracle官方的node-oracledb要求(地址),在7. Node-oracledb Installation on Windows 明确写明,

130257_QCH7_152000.png

必须 Visual Studio 2013 的  C/C++ 运行环境。vs2013 C/C++运行环境未找到官方下载地址,这里提供其他原地址:http://dl.pconline.com.cn/download/771041-1.html

2:配置的node-oracledb 编译环境。

这里很简单,根据官方提供文档,进行配置就好。以下是资料。

oracledb编译配置:https://community.oracle.com/docs/DOC-931127 (很详细)

node-gyp 编译说明:https://github.com/nodejs/node-gyp#installation

编译oracledb的时候,看到oracle的文档说明,下载相应软件 "basic" and "SDK",配置好环境变量 OCI_LIB_DIR and OCI_INC_DIR ,

npm install oracledb

133124_6aaJ_152000.png

这里有坑点:

坑点:node-gyp文档说明。明确了要vs2015 c++编译环境。所以,再次必须先下载vs2015 c++编译环境:https://www.microsoft.com/zh-cn/download/details.aspx?id=48145

133341_XB9y_152000.png

如果,没有看node-oracledb的运行要求,就会错过Visual Studio 2013 的  C/C++ 运行环境的安装,测试的时候,总是报 Error: The specified module could not be found.  错误。这里我折腾了好久。

请注意,node-gyp编译 oracledb是请采用vs2015 c++编译,运行用Visual Studio 2013 的  C/C++ 运行环境运行,切记。

3:测试


var oracledb = require('oracledb');
oracledb.getConnection(
  {
    user          : "TPM",
    password      : "TPM",
    connectString : "192.168.0.23/orcl"
  },
  function(err, connection)
  {
    if (err) {
      console.error(err.message);
      return;
    }
    console.log('Connection was successful!');
    connection.close(
      function(err)
      {
        if (err) {
          console.error(err.message);
          return;
        }
      });
  });

看到 Connection was successful! 恭喜完成。

----------------------------------------------

这里是重点!水平有限,以上介绍都是错的,出现oracledb error: the specified procedure could not be found 错误,是没把“basic”环境变量必须配置在PATH最前面!最前面!最前面!,被别的oracle环境变量影响,只要把basic配置在最前面即可,感谢一下网友。

162952_HUYe_152000.png

相关问题请查看 https://github.com/joeferner/node-oracle/issues/72

 

愿君顺利。

转载于:https://my.oschina.net/huqiji/blog/1550222

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值