Is there a way to execute Sequelize migrations with the ESM package? It requires the -r esm command line argument to be passed, but I don't seem to find that in their docs
1 Answer
I had the same issue and the way I got around it is by calling sequelize-cli from the node_modules folder.
In my package.json
{
"scripts": {
"migrate": "node --require esm ./node_modules/.bin/sequelize-cli db:migrate"
}
}
then if you run npm run migrate it should work with es6 imports.
3 Comments
dmikester1
Do you need to run that build script everytime before you run the
npm run migrate?Abir Taheer
@dmikester1 my apologies, I copied that over from an old project and forgot to change the name of the script. In this situation the
migrate script is what I was referring to in the build script.PirateApp
doesnt work still gives the same error, cannot use import statement outside module