错误:NJS"/>
错误:NJS
我在用 下一个:13.1.6 甲骨文数据库: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: .html
我的代码如下所示: \src pp ccounts ditUsernamePassword\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 bcHelper.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
当我做 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
回答如下:
使用 Webpack 和 node-oracledb 5.5,您需要 webpack.config.js 中的复制插件来复制 node-oracledb 二进制文件:
plugins: [
new CopyPlugin([
{
// Copy the binary Oracle DB driver to dist.
from: path.resolve(__dirname, 'node_modules/oracledb/build/Release'),
to: 'oracledb',
},
]),
. . .
],
提示在https://github/oracle/node-oracledb/issues/1156#issuecomment-598017250
更多推荐
错误:NJS
发布评论