dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

Path error when load model #699

Closed li-qiang closed 8 years ago

li-qiang commented 8 years ago

There is an error when loading model.

D:\workspace\PC2\node_modules\mysql\lib\protocol\Parser.js:77
        throw err; // Rethrow non-MySQL errors
        ^

Error: Cannot find module 'D:\workspace\PC2\initializers/D:\workspace\PC2\app\models\machine'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:289:25)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at ORM.<anonymous> (D:\workspace\PC2\node_modules\orm\lib\ORM.js:284:11)
    at ORM.load (D:\workspace\PC2\node_modules\orm\lib\ORM.js:294:9)
    at D:\workspace\PC2\initializers\database.js:13:8
    at Handshake._callback (D:\workspace\PC2\node_modules\orm\lib\ORM.js:133:13)
    at Handshake.Sequence.end (D:\workspace\PC2\node_modules\mysql\lib\protocol\sequences\Sequence.js:96:24)
    at Handshake.Sequence.OkPacket (D:\workspace\PC2\node_modules\mysql\lib\protocol\sequences\Sequence.js:105:8)

Code

orm.connect(dbConnection, (err, db) => {
    db.load(path.join(Consts.appDir, 'models', 'machine'), (err) => {
      if (err) throw err;
      models = db.models;
      db.sync((err) => {
        if (err) throw err;
      });
    });
  })

System is windows7.

Node version is 4.2.4

node-orm version is 2.1.29

dxg commented 8 years ago

Published ORM v 2.1.30 cc #700