node-oracle windows下编译安装

步骤1安装 oracle 11g

oracle官网下载orcale 11g ,【现在还是别用10g了】

2 安装 microsoft visual studio2012 express

使用microsoft visual studio2013安装没有成功,不过应该2013也可以。以后再试。

3 安装nodejs

最新版最好,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安装目录下的文件,放在后面时,有时候编译失败。

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的编译器设置为vs2012 
cmd执行:


npm config set msvs_version 2012 --global

2 中文字符乱码报错内容:


中文乱码

原因:

oracle 数据库和客户端需要统一设置字符编码;

解决:

  1. 建立oracle数据库时候设置数据库的字符编码 选择utf-8编码,默认设置中国的。

  2. 添加环境变量:

    NLS_LANG=SIMPLIFIED CHINESE_CHINA.AL32UTF8

3 编译成功后,再安装完Oracle后无法加载node-oracle模块错误描述:

在编译安装完成,并成功运行后,又安装 Oracle到本机,再次运行后,报错无法加载node-oracle模块。

原因:

编译时安装的模块是基于 instantclient_12_1进行编译的,以来模块也是instantclient_12_1,但再次安装oracle后,会在环境变量里的最前面添加:

?

1

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 后面。


转载于:https://my.oschina.net/u/2369810/blog/472184

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值