1

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 1

3

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.

Sign up to request clarification or add additional context in comments.

3 Comments

Do you need to run that build script everytime before you run the npm run migrate?
@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.
doesnt work still gives the same error, cannot use import statement outside module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.