question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot use ES6 imports in md-seed run command

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
antonkomarevcommented, Sep 2, 2019

Solved by adding .babelrc file with content:

{
  "presets": ["@babel/preset-env"]
}
0reactions
antonkomarevcommented, Sep 2, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I use an ES6 import in Node.js? - Stack Overflow
With esm you will be able to use export/import in your JavaScript files. Run the following command on your terminal yarn add esm....
Read more >
How to use an ES6 import in Node.js? - GeeksforGeeks
Create a file index.js and write the program using ES6 import. ... Now run the index.js file by typing node –experimental-modules index.js ...
Read more >
How to use ES6 import syntax in Node.js - DEV Community ‍ ‍
An ES6 import syntax allows importing modules exported from a ... Run the Node.js server either by using npm start or npm run...
Read more >
Mongoose-seed, Seeding MongoDB database the right way, Seed ...
Start the Docker container with the run command using the mongo image. The /data/db directory in the container is mounted as /mongodata on...
Read more >
Module Methods - webpack
No CommonJS allowed, for example, you can't use require , module.exports or ... webpack supports ES6 module syntax natively, meaning you can use...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found