tj / node-migrate

Abstract migration framework for node
MIT License
1.53k stars 221 forks source link

Use with ES6 modules #179

Open georgeben opened 3 years ago

georgeben commented 3 years ago

I have installed babel-register. However, when I run migrate up --compiler="js:babel-register" I get the error:

Error: Cannot find module 'babel-register'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at registerCompiler (/usr/local/lib/node_modules/migrate/lib/register-compiler.js:12:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/migrate/bin/migrate-up:57:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)

Please what am I doing wrong? I would appreciate any help. Thanks for this package @tj

wesleytodd commented 3 years ago

Hm, well I am not sure this has to do with ESM, the register-compiler cannot find the package. I would need more info to help debug, do you have a repo I could look at?

Ti-webdev commented 3 years ago

My pull request added support es6 modules without compiler You can use es6 modules in migrations with nodejs>=v12

https://github.com/tj/node-migrate/pull/185