Unexpected token 'export' using Sequelize v6.1.1
sequelize/sequelize#11950 Issue Description Using the new v6.1.1 sequelize and the accompanying sequelize-cli, I get an error trying to do anything. Error is: SyntaxError: Unexpected token 'export'
What are you doing?
npm install sequelize sequelize-cli --save-dev npx sequelize init
--> sequelize init throws the error above (stack trace below)
Alternate Steps: //do a simple test connection, per the documentation
--> running this code also throws the same error --> also, running all my examples that used to work, when I use sequelize v6.1.1 throw this same error. I have the code working properly with sequelize 4 and 5, but as soon as I install the latest, this error happens, seemingly anytime I try to call any sequelize method.
const {Sequelize} = require('sequelize');
const sequelize = new Sequelize('best_todo_ever', 'root', '', {
host: 'localhost',
dialect: 'mysql'
});
(async()=>{
try {
await sequelize.authenticate();
console.log('Connection has been established successfully.');
} catch (error) {
console.error('Unable to connect to the database:', error);
}
})()
What do you expect to happen?
npx sequelize init --> should run without error and initialize the folders, like it does in version 5 the js code should run and successfully test the connection
What is actually happening?
error occurs, always this same error
export { default as v1 } from './v1.js';
^^^^^^
SyntaxError: Unexpected token 'export'
at wrapSafe (internal/modules/cjs/loader.js:1055:16)
at Module._compile (internal/modules/cjs/loader.js:1103:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
at Module.load (internal/modules/cjs/loader.js:988:32)
at Function.Module._load (internal/modules/cjs/loader.js:896:14)
at Module.require (internal/modules/cjs/loader.js:1028:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\git-repos-bethn26\BootcampCoursework\Week14-Full-Stack\01-Activities\04-StarWars\Solved\node_modules\sequelize\lib\utils.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1139:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
Additional context
code works OK with version 4
Environment
- Sequelize version: XXX -- [email protected]
- Node.js version: XXX v13.5.0
- Operating System: Windows 10
- If TypeScript related: TypeScript version: N/A
Issue Template Checklist
How does this problem relate to dialects?
- [x ] I think this problem happens regardless of the dialect.
Would you be willing to resolve this issue by submitting a Pull Request?
- [ x] No, I don't have the time and I wouldn't even know how to start.
I'm having the same issue but with the import token. I've created a quick fix on my end by changing the index.js file to call the module with the sequelize instance rather than import it
Can you submit a sample project link which I can clone and check. Issue is in uuid it seems, as we are simply doing require('uuid'). Have you guys inspected node_modules/uuid code, does that looks ok?
I'm having the same issue but with the import token. I've created a quick fix on my end by changing the index.js file to call the module with the sequelize instance rather than import it
I noticed that the issue I had was fixed in a later release of sequelize-cli so ignore my comment in this thread because I don't think it's related to this issue.
Is this still an issue? I am currently experiencing the same problem as detailed above on 6.21?
Seems like it is. Just came across this with cli version 6.4.1.
Also tested with Sequelize CLI [Node: 16.19.1, CLI: 6.6.0, ORM: 6.29.3] - same problem.
I'm also having this problem with sequelize 6.5.0 and sequelize-cli 6.2.0. I fixed one ESM/ES6 issue where a require-ing module was using export instead of module.exports, but the problem continues to block execution of the seeders.