2017-08-30 323 views
0

我使用typeorm在JavaScript中的節點和快速的後端喜歡這裏:
https://typeorm.github.io/usage-with-javascript.htmlMissingDriverError當類型爲oracle:使用typeorm

節點版本v6.11.1
dipendencies從的package.json

"@types/es6-shim": "^0.31.35", 
    "@types/node": "^8.0.25", 
    "async": "^2.5.0", 
    "body-parser": "^1.17.2", 
    "cors": "^2.8.4", 
    "express": "^4.15.4", 
    "oracledb": "^1.13.1", 
    "reflect-metadata": "^0.1.10", 
    "typeorm": "0.1.0-alpha.35" 

這是我得到的錯誤:

Error: { Error 
     at new MissingDriverError (C:\Users\shodh\projects\NAPPATracking\node_modules\typeorm\error\MissingDriverError.js:22:23) 
     at DriverFactory.create (C:\Users\shodh\projects\NAPPATracking\node_modules\typeorm\driver\DriverFactory.js:40:23) 
     at new Connection (C:\Users\shodh\projects\NAPPATracking\node_modules\typeorm\connection\Connection.js:81:59) 
     at ConnectionManager.create (C:\Users\shodh\projects\NAPPATracking\node_modules\typeorm\connection\ConnectionManager.js:56:26) 
     at Object.<anonymous> (...\node_modules\typeorm\index.js:205:70) 
     at step (...\node_modules\typeorm\index.js:32:23) 
     at Object.next (...\node_modules\typeorm\index.js:13:53) 
     at ...\node_modules\typeorm\index.js:7:71 
     at __awaiter (...\node_modules\typeorm\index.js:3:12) 
     at Object.createConnection (...\node_modules\typeorm\index.js:196:12) 
     name: 'MissingDriverError', 
     message: 'Wrong driver undefined given. Supported drivers are: "mysql", "postgres", "mssql", "oracle", "mariadb", "sqlite".' } 

這裏是m奧德爾:

module.exports = { 
    name: "reagentsandconditionsnames", 
    columns: { 
     reagentnameid: { 
      primary: true, 
      type: "int", 
      generated: true 
     }, 
     reagentname: { 
      type: "string" 
     }, 
     datatype: { 
      type: "string" 
     }, 
     displayordernumber: { 
      type: "int" 
     } 
    } 
}; 

這裏就是我試圖訪問數據庫的代碼:

var typeorm = require("typeorm"); // import * as typeorm from "typeorm"; 
const oracledb = require('oracledb'); 
var reagentsandconditionsnames = require("./reagentsandconditionsnames"); // import {Post} from "./model/Post"; 
module.exports.getAllRandC = (callback) => { 
    typeorm.createConnection({ 
     driver: { 
      type: "oracle", 
      host: "localhost", 
      port: 1521, 
      username: "uname", 
      password: "pwd", 
      database: "dev" 
     }, 
     entitySchemas: [ 
      reagentsandconditionsnames 
     ], 
     autoSchemaSync: true 
    }).then(function (connection) { 
     console.log(connection); 
     // let rncnames = await connection.entityManager.find(reagentsandconditionsnames); 
     // console.log(rncnames); 
     callback(null, JSON.stringify("rncnames")); 
     }).catch(function(error) { 
     console.log("Error: ", error); 
    }); 
    } 

我在做什麼錯?

回答

0

你做的驅動程序安裝步驟? https://typeorm.github.io/index.html#installation

見本有關安裝節點OracleDB的細節: https://github.com/oracle/node-oracledb/blob/master/INSTALL.md

+0

是我沒有,我可以使用typeorm用了從數據庫中獲得數據的,當我使用typeorm不知它不認識司機 –

+0

我與其他類型的數據庫試圖不進行安裝和它同樣的錯誤! –

+0

我也嘗試註釋掉整個驅動線,我仍然得到同樣的錯誤好像它不是即使在讀取所有驅動程序的信息。 –

0

看起來像我用的是最新版本typeorm(0.1.0-alpha.35)當我刪除,並安裝了穩定版(0.0.11)錯誤消失了!

,但現在我不能以某種方式使用的連接,我得到以下錯誤,當我做

let rncnames = await connection.entityManager.find(reagentsandconditionsnames); 

在連接

let rncnames = await connection.entityManager.find(reagentsandconditionsnames); 

SyntaxError: Unexpected identifier 
    at createScript (vm.js:56:10) 
    at Object.runInThisContext (vm.js:97:10) 
    at Module._compile (module.js:542:28) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 

感謝您的幫助!

+0

你正在運行什麼版本的Node.js?您需要v7.6 +才能使用「等待」。 –

+0

是,這是問題之一,所以我回去,並試圖讓事情在相同的例子那樣工作在這裏https://github.com/typeorm/javascript-example/tree/master/src/app3-es6 –

相關問題