sharvit/mongoose-data-seed

Cannot use ES6 imports in md-seed run command

Closed this issue · 6 comments

I have babel packages installed in project and ES6 imports are working well, but they are not working in mongoose-data-seed.

Here are my Babel dependencies:

"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
"@babel/node": "^7.5.5",
"@babel/preset-env": "^7.5.5",

I'm submitting a…

  • Regression (a behavior that used to work and stopped working in a new release)
  • Bug report
  • Feature request
  • Documentation issue or request
  • Support request

Expected Behavior

Run seeders.

Current Behavior

Throwing exception when running $ md-seed run

/home/test-app/md-seed-config.js:1
(function (exports, require, module, __filename, __dirname) { import mongoose from 'mongoose';
                                                                     ^^^^^^^^

SyntaxError: Unexpected identifier

Environment

  • mongoose-data-seed version: 2.1.3
  • Node version: v11.6.0
  • Yarn version: 1.17.3
  • Operating system: Linux

Solved by adding .babelrc file with content:

{
  "presets": ["@babel/preset-env"]
}

Could you try using:

{
  "presets": ["@babel/env"]
}

It might be related to your issue.

I'm using this preset:

{
  "presets": ["@babel/preset-env"]
}

If I add @babel/env:

{
  "presets": ["@babel/preset-env", "@babel/env"]
}

It throws an error:

Error: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

Don't add, replace

I've noticed that you've added comment to already solved issue and I continued to reply to you here, but mention issue #45. Moved comments with solution to appropriate issue.