Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

upgrading from v6.3.0 to v6.4.0 breaks sequelize-cli #994

Closed
MichaelTaylor3D opened this issue Jan 14, 2022 · 11 comments · Fixed by #995
Closed

upgrading from v6.3.0 to v6.4.0 breaks sequelize-cli #994

MichaelTaylor3D opened this issue Jan 14, 2022 · 11 comments · Fixed by #995

Comments

@MichaelTaylor3D
Copy link

Project works fine when migrating with v6.3.0, it breaks when using v6.4.0. I have tried using the file:// scheme as it asks but it didnt make a difference in the error.

Sequelize CLI [Node: 16.0.0, CLI: 6.4.0, ORM: 6.13.0]

ERROR: Error reading "src\config\config.cjs". Error: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only file and data URLs are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'c:'

.sequalizerc

var path = require('path');

module.exports = {
  config: path.resolve('src', 'config', 'config.cjs'),
  'migrations-path': path.resolve('migrations'),
  'models-path': path.resolve('src', 'models'),
  'seeders-path': path.resolve('seeders'),
};

config.cjs

require('dotenv').config();

module.exports = {
  local: {
    dialect: 'sqlite',
    storage: './data.sqlite3',
  },
  test: {
    dialect: 'sqlite',
    storage: './test.sqlite3',
  },
  mirrorTest: {
    dialect: 'sqlite',
    storage: './testMirror.sqlite3',
  },
  mirror: {
    username: process.env.DB_USERNAME,
    password: process.env.DB_PASSWORD,
    database: process.env.DB_NAME,
    host: process.env.DB_HOST,
    dialect: 'mysql',
  },
};
@ephys
Copy link
Member

ephys commented Jan 14, 2022

Have you tried path.resolve('./src', 'config', 'config.cjs')?

@MichaelTaylor3D
Copy link
Author

I added the ./src but received the same error
image

the suggestion to use ./src still works on v6.3.0
image

@ephys
Copy link
Member

ephys commented Jan 14, 2022

So the issue is that import() expects paths that start either with ./ or file://. C:\\ as path.resolve outputs isn't valid.

While we work on a solution, you'll need to specify the path without using path.resolve :/

@ephys
Copy link
Member

ephys commented Jan 14, 2022

Maybe url.pathToFileURL(path.resolve('./src', 'config', 'config.cjs')).href might work

@MichaelTaylor3D
Copy link
Author

Was just about to post this, I attempted this before I reported the issue and received a different error:
image

@ephys
Copy link
Member

ephys commented Jan 14, 2022

Damn. We use path.resolve ourselves on it https://github.com/sequelize/cli/blob/main/src/helpers/config-helper.js#L46 which completely breaks your path.

I don't have a hotfix to give you :/, we need to fix that in the cli

@MichaelTaylor3D
Copy link
Author

My solution for now is to downgrade to v6.3.0. But wanted to report this error with v6.4.0. If you would like any more information about the env, would be happy to post.

@ephys
Copy link
Member

ephys commented Jan 15, 2022

I think the fix is simple, I need replace this line
https://github.com/sequelize/cli/blob/main/src/helpers/import-helper.js#L24
with await import(url.pathToFileURL(modulePath)). Just need to setup a work environment on windows to test it.

It went unnoticed on UNIX because paths already look like URLs.

@ephys ephys changed the title upgrading from v6.3.0 to v6.4.0 breaks sequalize-cli upgrading from v6.3.0 to v6.4.0 breaks sequelize-cli Jan 15, 2022
@ephys
Copy link
Member

ephys commented Jan 15, 2022

Managed to reproduce it and solution is as above. I'll open a PR

@WikiRik
Copy link
Member

WikiRik commented Jan 15, 2022

We published a new version (6.4.1) which should have fixed this issue. Let us know if it works or not. Thanks again for reporting it!

@MichaelTaylor3D
Copy link
Author

v6.4.1 worked for me, thank you!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants