U-Wreckcar / U-wreckcar-BE

๋งˆ์ผ€ํ„ฐ๋ฅผ ์œ„ํ•œ UTM ์นดํ…Œ๊ณ ๋ผ์ด์ง• ๋ฐ ์ƒ์„ฑ/๊ด€๋ฆฌ ์„œ๋น„์Šค
https://utm.works
1 stars 1 forks source link

๐Ÿ› `npx sequelize db:migrate` ํ•  ๋•Œ babel version error #14

Open tastekim opened 1 year ago

tastekim commented 1 year ago

์—๋Ÿฌ ๋‚ด์šฉ

ERROR: Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of 
@babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this 
error to look for the first entry that doesn't mention "@babel/core" or "babel-core" to see what is calling Babel. (While 
processing preset: "/Users/tastekim/Desktop/study/u-wreckcar-be/node_modules/@babel/preset-env/lib/index.js")
tastekim commented 1 year ago

TEST 1

// model/index.js
import fs from 'fs';
import path from 'path';
import Sequelize from 'sequelize';
import process from 'process';

const basename = path.basename(new URL(import.meta.url).pathname);
const env = process.env.NODE_ENV || 'development';
const config = import('../config/config.js')[env];
const db = {};

let sequelize;
if (config.use_env_variable) {
  sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
  sequelize = new Sequelize(config.database, config.username, config.password, config);
}

fs
    .readdirSync(path.dirname(new URL(import.meta.url).pathname))
    .filter(file => {
      return (
          file.indexOf('.') !== 0 &&
          file !== basename &&
          file.slice(-3) === '.js' &&
          file.indexOf('.test.js') === -1
      );
    })
    .forEach(file => {
      const model = import(path.join(path.dirname(new URL(import.meta.url).pathname), file)).default;
      db[model.name] = model(sequelize, Sequelize.DataTypes);
    });

Object.keys(db).forEach(modelName => {
  if (db[modelName].associate) {
    db[modelName].associate(db);
  }
});

sequelize.sync({ force: true });

// force true ์‹œ ๋””๋น„ ๋‚ ๋ ค๋ฒ„๋ฆฌ๊ณ  ์ƒˆ๋กœ๋งŒ๋“ญ๋‹ˆ๋‹ค! ์ฒซ์‹คํ–‰ ํ›„ ๊ผญ false๋กœ ๋ฐ”๊ฟ”์ฃผ๊ธฐ!

export { sequelize, Sequelize };

export default db;
// config/config.js
import 'dotenv/config';

const config = {
    development: {
        username: process.env.RDS_USERNAME,
        password: process.env.RDS_PASSWORD,
        database: process.env.RDS_DBNAME,
        host: process.env.RDS_HOST,
        dialect: 'mysql',
    },
    test: {
        username: 'root',
        password: null,
        database: 'database_test',
        host: '127.0.0.1',
        dialect: 'mysql',
    },
    production: {
        username: 'root',
        password: null,
        database: 'database_production',
        host: '127.0.0.1',
        dialect: 'mysql',
    },
};

export default config;

npx sequelize-cli db:migrate:status --config "config/config.js" --env "development"

Sequelize CLI [Node: 16.16.0, CLI: 6.6.0, ORM: 6.28.0]

Loaded configuration file "config/config.js".

ERROR: Dialect needs to be explicitly supplied as of v4.0.0
tastekim commented 1 year ago

ํ•ด๊ฒฐ

์ ์šฉ ๋‚ด์šฉ

แ„‰แ…ณแ„แ…ณแ„…แ…ตแ†ซแ„‰แ…ฃแ†บ 2023-03-12 แ„‹แ…ฉแ„Œแ…ฅแ†ซ 3 45 18