如何解决Angular [错误:NJS-045] @nguniversal/express-engine SSR 无法为 Node.js 加载 node-oracledb 二进制文件
我正在 Angular 上做一个简单的项目:^11 + @nguniversal/express-engine for SSR。在我的项目中,我尝试使用 OracleDB
[Docker: store/oracle/database-enterprise:12.2.0.1] 在服务器端为动态 Web 应用程序创建 REST-API。
在使用 oracledb 打开池时出现如下错误:
D:\project\server\main.js:149903
throw new Error(nodbUtil.getErrorMessage('NJS-045',nodeInfo));
^
Error: NJS-045: cannot load a node-oracledb binary for Node.js 12.18.3 (win32 x64)
Looked for D:\project\dist\project\build\Release\oracledb-5.1.0-win32-x64.node,D:\project\dist\project\build\Release\oracledb.node,D:\project\dist\project\build\Debug\oracledb.node,D:\project\dist\project\server\node_modules\oracledb\build\Release\oracledb-5.1.0-win32-x64.node,D:project\dist\project\server\node_modules\oracledb\build\Release\oracledb.node.....
我在 TypeScript 中尝试过这个类,效果很好,但 angular 不行。
import * as oracledb from 'oracledb';
import Connections from '../config/connections';
class Database {
public openConnections = async () => {
const connection = new Connections().getInfo();
try {
oracledb.initOracleClient({
libDir: 'D:\\lib\\instantclient_19_9',});
await oracledb.createPool({
user: connection.user,password: connection.password,connectionString: connection.connectString,poolAlias: connection.poolAlias,poolMin: connection.poolMin,poolMax: connection.poolMax,poolIncrement: connection.poolIncrement,});
} catch (error) {
console.warn(error);
}
}
}
我在服务器创建之前调用 server.ts
中的 Database 类...
...
...
endpoints(application);
await new Database().openConnections();
server.listen(port,() => {
console.log(`Node Express server listening on http://localhost:${port}`);
});
}
...
...
这个数据库类有问题还是...?
参考:
Angular CLI: 11.0.5
Node: 12.18.3
Angular: 11.0.5
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。