我在用着
下一个:13.1.6
oracledb:5.5.0
我收到以下错误:
Server Error
Error: NJS-045: cannot load a node-oracledb binary for Node.js 18.14.0 (win32 x64)
Looked for
C:\path\to\my\project\MyProjectName\.next\server\app\accounts\build\Release\oracledb-5.5.0-win32-x64.node,
C:\path\to\my\project\MyProjectName\.next\server\app\accounts\build\Release\oracledb.node,
C:\path\to\my\project\MyProjectName\.next\server\app\accounts\build\Debug\oracledb.node,
C:\path\to\my\project\MyProjectName\.next\server\app\accounts\editUsernamePassword\node_modules\oracledb\build\Release\oracledb-5.5.0-win32-x64.node,
C:\path\to\my\project\MyProjectName\.next\server\app\accounts\editUsernamePassword\node_modules\oracledb\build\Release\oracledb.node
Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
我的代码如下所示:
\src\app\accounts\editUsernamePassword\page.js
\\first line of code
import {oracleDB} from '@/library/database/oracle';
\src\library\database\oracle.js
const oracledb = require('oracledb');
//this is how to point to the Oracle Client without editing the PATH variable.
try {
oracledb.initOracleClient({libDir: "C:\\pathToMyInstantClient\\oracle\\instantclient_21_9"});
} catch (err) {
console.error('Unable to locate Oracle Instant Client.');
console.error(err);
process.exit(1);
}
/// ... then, go on to use the oracledb object
第一个问题。从错误消息来看,它似乎无法找到 oracledb*.node 文件。那是对的吗?起初,我以为没有找到 Oracle Instant Client,但事实似乎并非如此。相反,问题是它找不到 oracledb*.node 文件。
其次,如果我的假设(1)是正确的,为什么它要寻找相对于应用程序/帐户页面的 oracledb*.node ?
我想我可以将文件复制到那里,但随后我需要将客户端复制到需要它的每个路径。
难道不应该在这里找吗:?我已确认 oracledb*.node 文件位于此处:
C:\path\to\my\project\MyProjectName\node_modules\oracledb\build\Release
让我更加困惑的是,这种导入并不总是失败。
我还有另一个文件:
\src\library\oasis\abcHelper.js
\\first line of code
import {oracleDB} from '@/library/database/oracle';
//then, it goes on to successfully use the oracle library
我不知道为什么 abcHelper.js 能够加载该库,但 page.js 在错误的位置查找该库?
我确实在 oracledb.js 中看到了这个评论,看起来他们正在讨论这个问题,但我不确定如何实现该解决方案:
// For Webpack. A Webpack copy plugin is still needed to copy 'node_modules/oracledb/build/' to the output directory
// See https://github.com/oracle/node-oracledb/issues/1156
当我做
npm run dev,我收到此警告,但我不确定这是否是根本原因。
wait - compiling /accounts/editUsernamePassword/page (client and server)...
warn - ./node_modules/oracledb/lib/oracledb.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
Import trace for requested module:
./node_modules/oracledb/lib/oracledb.js
./node_modules/oracledb/index.js
./src/library/database/oracle.js
./src/app/accounts/editUsernamePassword/page.js
我当前的 next.config.js:
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
}
module.exports = nextConfig