How can we import users
schema modal in server.js file in ES6
way. Even though I have added type: module
in package.json file it doesn't work, throws below error.
note: I am trying to import all of the other modules in ES6 way.
sequelize user.js
'use strict';
module.exports = (sequelize, DataTypes) => {
const users = sequelize.define('users', {
id: {
type: DataTypes.INTEGER(10),
allowNull: false,
primaryKey: true,
autoIncrement: true
},
email: {
type: DataTypes.STRING(100),
allowNull: false
},
password: {
type: DataTypes.STRING(100),
allowNull: false
}
}, {
timestamps: true,
tableName: 'users'
});
return users;
};
and in the server.js
import usersSchema from "./modals/users.js";
Throws below error in console:
node:40244)
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
C:\Project\study\matblogs\src\server.js:23