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

Unexpected Identifier - Cannot find whats wrong #46

Open
adnanchang opened this issue Sep 18, 2019 · 3 comments
Open

Unexpected Identifier - Cannot find whats wrong #46

adnanchang opened this issue Sep 18, 2019 · 3 comments

Comments

@adnanchang
Copy link

adnanchang commented Sep 18, 2019

Hi,

So I setup everything, including a migrate.json file and created the migration using:

migrate create dark-theme-apply
/* eslint-disable no-param-reassign */
import Setting from '../src/server/models/Setting';

/**
 * Make any changes you need to make to the database here
 */
async function up() {
  // Write migration here
  await new Promise((resolve, reject) => {
    try {
      const settingsToChange = Setting.find({ darkTheme: { $exists: false } });

      settingsToChange.forEach((setting) => {
        setting.darkTheme = false;
        setting.save();
      });

      resolve();
    } catch (err) {
      reject(err);
    }
  });
}

/**
 * Make any changes that UNDO the up function side effects here (if possible)
 */
async function down() {
  // Write migration here
}

export default { up, down };

On running the following command

migrate up dark-theme-apply

I get the following error:

(node:10208) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

Synchronizing database with file system migrations...
Unexpected identifier

EDIT: Apparently, the error goes away when I dont use import but then when I use require it still doesnt work

@vslepkan
Copy link

vslepkan commented Oct 3, 2019

I have the same problem. Any updates?

@JSandmark
Copy link

Hi! It sounds like you normally use Babel or something to build your js.
The file you used to import, but now require in your migration file, could you please verify that that file does not contain imports / export default directly or indirectly in nested requires?

@vslepkan
Copy link

vslepkan commented Dec 9, 2019

Hi,
But it contains ES6 modules like in examples from the readme.

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

3 participants