0

我有一个简单的 node.js 服务器和一些在其上运行的应用程序,它应该连接到 Oracle 数据库。出于这个原因,我决定使用node-oracledb驱动程序,但我在安装时遇到了一些问题。我按照Oracle 网页github上的说明进行操作,但下面仍然出现错误。

我的环境配置:

  • Windows 8.1 专业版 64 位
  • node.js v6.4.0
  • npm v3.10.3
  • MS Visual Studio 2013 社区版
  • Python v2.7.12
  • Oracle Instant Client (基础+ SDK) v12.1.0.2.0

Node、Python 和 Oracle Instant Client 文件夹包含在 PATH 变量中。OCI_LIB_DIR 和 OCI_INC_DIR 也是根据github指令设置的。

这是问题所在:当我执行 command 时npm install oracledb -g,出现以下错误:

> oracledb@1.11.0 install C:\Users\pr\AppData\Roaming\npm\node_modules\ora
cledb
> node-gyp rebuild


C:\Users\pr\AppData\Roaming\npm\node_modules\oracledb>if not defined npm_c
onfig_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\
\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )

Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
C:\Users\pr\AppData\Roaming\npm\node_modules\oracledb\build\oracledb.vcxp
roj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props"
 was not found. Confirm that the path in the <Import> declaration is correct, a
nd that the file exists on disk.
gyp ERR! build error
gyp ERR! stack Error: `msbuild` 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:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_proces
s.js:204:12)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodej
s\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\pr\AppData\Roaming\npm\node_modules\oracledb
gyp ERR! node -v v6.4.0
gyp ERR! node-gyp -v v3.3.1
gyp ERR! not ok
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\
node_modules\\npm\\bin\\npm-cli.js" "install" "oracledb" "-g"
npm ERR! node v6.4.0
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE

npm ERR! oracledb@1.11.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the oracledb@1.11.0 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the oracledb package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs oracledb
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls oracledb
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\pr\Development\Visual Studio 2013\npm-debug.log

我真的不知道在哪里寻找解决方案。什么可能导致该错误?节点/oracle 客户端/python 之间是否存在任何已知的不兼容性?

还有一件事:github指令说:

确保正确设置 Microsoft Visual Studio 环境变量。使用 set PATH 并验证它是否包含您的 Visual Studio 路径。如果未设置,请使用 vcvars64.bat(如果使用 32 位二进制文​​件构建,则使用 vcvars.bat)设置环境。

应该设置哪些 VS 环境变量,哪些 VS 路径应该包含在 PATH 中?

4

2 回答 2

1

oracledb 或 node-oracledb 等模块需要编译。编译需要C编译器、Python等软件。

我在使用 oracldb 模块时遇到了同样的问题。按照以下说明操作,它就像魅力一样。

https://community.oracle.com/docs/DOC-931127

于 2017-05-25T14:21:25.720 回答
0

尝试将 npm 更新到最新版本:

npm install -g npm

如果它仍然不起作用,请尝试像这样包含您的 VS 版本:

npm install oracledb --msvs_version=2013
于 2016-08-26T12:42:13.060 回答