开发是采用Mac环境,部署服务器是Windows 08,中间卡壳好久。以下是windoes发布编译方法和注意点。
1:下载 Visual Studio 2013 的 C/C++ 运行环境
首先根据oracle官方的node-oracledb要求(地址),在7. Node-oracledb Installation on Windows 明确写明,
必须 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
这里有坑点:
坑点:node-gyp文档说明。明确了要vs2015 c++编译环境。所以,再次必须先下载vs2015 c++编译环境:https://www.microsoft.com/zh-cn/download/details.aspx?id=48145
如果,没有看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配置在最前面即可,感谢一下网友。
相关问题请查看 https://github.com/joeferner/node-oracle/issues/72
愿君顺利。