Javascript 浏览器中的节点oracledb错误“;尚未为上下文加载模块名称“0”;

Javascript 浏览器中的节点oracledb错误“;尚未为上下文加载模块名称“0”;,javascript,html,node.js,node-oracledb,Javascript,Html,Node.js,Node Oracledb,我正在尝试使用节点oracledb从oracle数据库加载数据,我收到以下错误: Error: Module name "select1" has not been loaded yet for context: _. Use require([]) 我确实读了文档,但我想不出解决方案。为什么它会给我这样的错误,为什么还要感谢你的帮助 选择1.js: const oracledb = require('oracledb'); const dbConfig = require('./

我正在尝试使用节点oracledb从oracle数据库加载数据,我收到以下错误:

Error: Module name "select1" has not been loaded yet for context: _. Use require([])
我确实读了文档,但我想不出解决方案。为什么它会给我这样的错误,为什么还要感谢你的帮助

选择1.js:

   const oracledb = require('oracledb');
   const dbConfig = require('./dbconfig.js');
   const demoSetup = require('./demosetup.js');
   oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
   async function run() {
   let connection;

   try {
   // Get a non-pooled connection

  connection = await oracledb.getConnection(dbConfig);

  await demoSetup.setupBf(connection);  // create the demo table

  var query = await connection.execute(
    // The statement to execute
    `SELECT * From pilote`,

    // The "bind value" 3 for the bind variable ":idbv"
    [],

    // Options argument.  Since the query only returns one
    // row, we can optimize memory usage by reducing the default
    // maxRows value.  For the complete list of other options see
    // the documentation.
    {
      maxRows: 100
      //, outFormat: oracledb.OUT_FORMAT_OBJECT  // query result format
      //, extendedMetaData: true                 // get extra metadata
      //, fetchArraySize: 100                    // internal buffer allocation size for tuning
    });
    //console.log(query.rows)

} catch (err) {
  console.error(err);
} finally {
  if (connection) {
    try {
      // Connections should always be released when not needed
      //await connection.close();
    } catch (err) {
      console.error(err);
    }
  }
}
return query;
}
module.exports.run =  run;
test.js:

(async() =>{
var result = require('./select1').run()
var rs;
rs = (await result).rows
if(rs !== undefined)
{
    document.getElementById('hdr').textContent = rs[0]
}
})()
page.html:

<body>
<h1 id="hdr">hello</h1>
<script src="https://requirejs.org/docs/release/2.3.5/minified/require.js"></script>
<script  src="test.js"></script>
</body>

你好

节点oracledb将不会在浏览器中运行,因为它具有需要访问二进制共享库的二进制组件。标准的Node.js应用程序设计将Node.js作为中间层应用程序服务器,接受来自broswer的网络调用(如REST),并将数据返回到浏览器。有一些使用变体,例如作为使用Electron的独立应用程序


如果这对您来说都是新的,请从示例开始,直到

事实上,我正试图使用节点oracle db连接到我的electron应用程序,但我想先在浏览器中尝试,因此,它不起作用。但当我用electron运行它时,一切都很好。所以我很困惑为什么我的浏览器不支持它。这就是原因。无论如何,谢谢你的回答。