Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

New error - sequelize.import is not a function while npm start #26

Open
akshaya-kd opened this issue May 23, 2021 · 2 comments
Open

New error - sequelize.import is not a function while npm start #26

akshaya-kd opened this issue May 23, 2021 · 2 comments

Comments

@akshaya-kd
Copy link

Getting Below error while performing npn start

D:\BestBuyAPI\api-playground>npm start

[email protected] start
node src/

D:\BestBuyAPI\api-playground\src\db\index.js:36
var model = sequelize['import'](path.join(__dirname, file));
^

TypeError: sequelize.import is not a function
at D:\BestBuyAPI\api-playground\src\db\index.js:36:38
at Array.forEach ()
at Function.setupDatabase (D:\BestBuyAPI\api-playground\src\db\index.js:35:6)
at Function.configure (D:\BestBuyAPI\api-playground\node_modules\feathers\lib\application.js:150:8)
at Function.module.exports (D:\BestBuyAPI\api-playground\src\services\index.js:11:7)
at Function.configure (D:\BestBuyAPI\api-playground\node_modules\feathers\lib\application.js:150:8)
at Object. (D:\BestBuyAPI\api-playground\src\app.js:31:4)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)

@akshaya-kd
Copy link
Author

Please refer the below index file details

  1. fs.readdirSync(__dirname)
  2. .filter(function (file) {
  3. return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
    
  4. })
  5. .forEach(function (file) {
  6.  var model = sequelize['import'](path.join(__dirname, file));
    
  7.  db[model.name] = model;
    
  8. });

@anktyagi
Copy link

Replace
var model = sequelize['import'](path.join(__dirname, file));
to
var model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes);

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

No branches or pull requests

2 participants