node-oracle windows下编译安装
2015-10-26 16:57
465 查看
摘要: node-oracle windows下编译安装下的记录
下载
确保 Path 中 c:\instantclient_12_1\vc11 在 c:\instantclient_12_1 前面,最好放在最前面,安装了oracle后,如果放到后面可能会调用oracle安装目录下的文件,放在后面时,有时候编译失败。
【在编译完成后,为了安装oracle官网的node-oracledb , 更改 OCI_LIB_DIR=C:\instantclient_12_1\sdk\lib\msvc, 原来编译好的 oracle驱动可以继续使用,也就是说,OCI_LIB_DIR只用于编译过程。】
环境变量path里添加
建议全局安装,因为在不同的机器上需要编译不同的版本,省得再在协同开发时,导致不同人员的冲突,尤其是使用GIT时候。
cmd执行:
添加环境变量:
NLS_LANG=SIMPLIFIED CHINESE_CHINA.AL32UTF8
c:\app\SatanRabbit\product\11.2.0\dbhome_1\bin;
\dbhome_1\bin 里面的 oci.dll 等于编译时配置的不一致,导致无法加载依赖项。
步骤
1安装 oracle 11g
oracle官网下载orcale 11g ,【现在还是别用10g了,反正我没有用】2 安装 microsoft visual studio2012 express
使用microsoft visual studio2013安装没有成功,不过应该2013也可以。以后再试。
3 安装nodejs
最新版最好【暂时只能用node0.10版本的,0.12版本的不行】,npm在1.3.15版本以前node-gyp在编译时会调用
VCBuild.exe,在vs2012下是找不到的
VCBuild.exe的。
4 安装 oracle instant client
【32位系统选择对应的32位版本】
下载
Version 12.1.0.1.0中的
instantclient-basic-windows.x64-12.1.0.1.0.zip和
instantclient-sdk- windows.x64-12.1.0.1.0.zip; 并把它们解压到
C:\instantclient_12_1文件夹中, 由于两个 zip 中的文件各不相同, 所以合并到同一个文件夹也不会发生覆盖。
5 设置环境变量
OCI_INCLUDE_DIR=C:\instantclient_12_1\sdk\include OCI_LIB_DIR=C:\instantclient_12_1\sdk\lib\msvc\vc11 OCI_VERSION=12 Path=c:\instantclient_12_1\vc11;c:\instantclient_12_1;...
确保 Path 中 c:\instantclient_12_1\vc11 在 c:\instantclient_12_1 前面,最好放在最前面,安装了oracle后,如果放到后面可能会调用oracle安装目录下的文件,放在后面时,有时候编译失败。
【在编译完成后,为了安装oracle官网的node-oracledb , 更改 OCI_LIB_DIR=C:\instantclient_12_1\sdk\lib\msvc, 原来编译好的 oracle驱动可以继续使用,也就是说,OCI_LIB_DIR只用于编译过程。】
6 安装 python2.7
安装python2.7,
3.x版本不行,node-gyp不支
3.x·,
环境变量path里添加
;C:\Python27,如果安装了3.x版本的要从环境变量里移除!
7 安装 node-gyp
cmd命令窗口里:npm install -g node-gyp
8 安装 node-oracle
cmd:npm install -g oracle
建议全局安装,因为在不同的机器上需要编译不同的版本,省得再在协同开发时,导致不同人员的冲突,尤其是使用GIT时候。
错误处理
1 MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe".
报错内容:
MSBUILD : error MSB3411: Could not load the Visual C++ component "VCBuild.exe". If the component is not installed, either 1) install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5, or 2) install Microsoft Visual Studio 2008. [C:\Users\Administrator\AppData\Roaming\npm\node_modules\oracle\ build\binding.sln] gyp ERR! build error gyp ERR! stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1 gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:267:23) gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17) gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12) gyp ERR! System Windows_NT 6.1.7601 gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" gyp ERR! cwd C:\Users\Administrator\AppData\Roaming\npm\node_modules\oracle gyp ERR! node -v v0.10.21 gyp ERR! node-gyp -v v0.10.10 gyp ERR! not ok npm ERR! weird error 1 npm ERR! not ok code 0
原因
npm在1.3.15版本以前node-gyp在编译时会调用
VCBuild.exe,在vs2012下是找不到的
VCBuild.exe,vs2012及以后版本是msbuild.exe作为编译器。
解决:
将npm 的 msvs的编译器设置为vs2012cmd执行:
npm config set msvs_version 2012 --global
2 中文字符乱码
报错内容:
中文乱码
原因:
oracle 数据库和客户端需要统一设置字符编码;解决:
建立oracle数据库时候设置数据库的字符编码 选择utf-8编码,默认设置中国的。
添加环境变量:
NLS_LANG=SIMPLIFIED CHINESE_CHINA.AL32UTF8
3 编译成功后,再安装完Oracle后无法加载node-oracle模块
错误描述:
在编译安装完成,并成功运行后,又安装 Oracle到本机,再次运行后,报错无法加载node-oracle模块。原因:
编译时安装的模块是基于 instantclient_12_1进行编译的,以来模块也是instantclient_12_1,但再次安装oracle后,会在环境变量里的最前面添加:c:\app\SatanRabbit\product\11.2.0\dbhome_1\bin;
\dbhome_1\bin 里面的 oci.dll 等于编译时配置的不一致,导致无法加载依赖项。
解决:
在环境变量 Path中,把c:\app\SatanRabbit\product\11.2.0\dbhome_1\bin;放置在
c:\instantclient_12_1后面。
相关文章推荐
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- Oracle Containers for J2EE远程安全漏洞(CVE-2014-0413)
- Oracle 10g R2不能使用EM的问题
- 表空间操作
- PreparedStatement中in子句的处理
- VMware下RedHat4.8_64位安装Oracle 10g RAC--简略脚本
- oracle sql日期比较
- 基于 Red Hat 的发行版 Oracle Linux 正式发布Oracle Linux 7.1
- OS block size和Oracle block size,查找OS Blocksize的方法
- oracle中创建数据库和表空间的几点总结
- 数据库自动备份脚本
- oracle的nvl函数的使用介绍
- 解决oracle用户连接失败的解决方法
- oracle的一些tips技巧
- Oracle 下的开发日积月累
- Oracle存储过程之数据库中获取数据实例
- Windows下ORACLE 10g完全卸载的方法分析
- Oracle 函数大全[字符串函数,数学函数,日期函数]第1/4页