ORA-12514错误,同时使用节点oracle-db npm packagae

目前,我正在开发一个需要后端在oracle完成的项目。 我使用了给定的链接,并在我的Mac上使用npm安装了node-oracledb 。 我的文件内容如下

 var oracledb = require('oracledb'); oracledb.getConnection( { user : 'username', password : 'password', connectString : 'username/password//hostname:port/sid' function(err, connection) { if (err) { console.error(err.message); return; }else{ connection.execute( "SELECT * from TableName", function(err, result) { if (err) { console.error(err); return; } console.log(result.rows); }); } }); 

当我运行节点filename.js我得到以下错误

 ORA-12154: TNS:could not resolve the connect identifier specified 

我使用的节点版本是v7.0.0 ,npm版本是v3.10.8 。 另外我的oracle数据库是云上的11g实例。 有人可以让我知道我做错了什么吗?

它看起来像你的connectString是错误的,根据Docs不只是主机名:端口/ sid

 var oracledb = require('oracledb'); oracledb.getConnection( { user : "hr", password : "welcome", connectString : "hostname:port/sid" }) .then(function(conn) { return conn.execute( "SELECT department_id, department_name " + "FROM departments " + "WHERE manager_id < :id", [110] // bind value for :id ) .then(function(result) { console.log(result.rows); return conn.close(); }) .catch(function(err) { console.error(err); return conn.close(); }); }) .catch(function(err) { console.error(err); });