Closed arketec closed 4 years ago
Are you running Node 8? If so, try to upgrade to Node 10 (or higher). I'm pretty sure that is the issue. Can you confirm this please? Thank you.
I don't think it's that, as I am trying to initialize a migrate-mongo (v8.1.1) project freshly and getting the same error. On a docker image that is running node 10.16.3
I have just tested with node 10.16.3, and I can initialize a project, migrate up and get the status without any problem?
$ node -v
v10.16.3
$ mkdir test-project
$ cd test-project
$ migrate-mongo init
Initialization successful. Please edit the generated `migrate-mongo-config.js` file
$ migrate-mongo create "abc"
Created: migrations/20200722153528-abc.js
$ migrate-mongo up
MIGRATED UP: 20200722153528-abc.js
$ migrate-mongo status
┌───────────────────────┬──────────────────────────┐
│ Filename │ Applied At │
├───────────────────────┼──────────────────────────┤
│ 20200722153528-abc.js │ 2020-07-22T15:35:31.956Z │
└───────────────────────┴──────────────────────────┘
You were right about it being node 8. Our build machine was running node 8 and after upgrading to node 10.16.3 the script functioned properly. Thanks for the assist!
I'm closing this issue.
I have a migration script that works without issue on my local version of migrate-mongo (v4.1.2) but fails on the latest version (v8.1.1)
here is the information:
script: `module.exports = { async up(db) { // TODO write your migration here. Return a Promise (and/or use async & await). // See https://github.com/seppevs/migrate-mongo/#creating-a-new-migration-script // Example: // return db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: true}});
},
async down(db) { // TODO write the statements to rollback your migration (if possible) // Example: // return db.collection('albums').updateOne({artist: 'The Beatles'}, {$set: {blacklisted: false}});
} }; `
And here is the console output:
console log:
17:51:34 /usr/local/lib/node_modules/migrate-mongo/node_modules/fs-extra/lib/mkdirs/make-dir.js:85 17:51:34 } catch { 17:51:34 ^ 17:51:34 17:51:34 SyntaxError: Unexpected token { 17:51:34 at createScript (vm.js:80:10) 17:51:34 at Object.runInThisContext (vm.js:139:10) 17:51:34 at Module._compile (module.js:617:28) 17:51:34 at Object.Module._extensions..js (module.js:664:10) 17:51:34 at Module.load (module.js:566:32) 17:51:34 at tryModuleLoad (module.js:506:12) 17:51:34 at Function.Module._load (module.js:498:3) 17:51:34 at Module.require (module.js:597:17) 17:51:34 at require (internal/module.js:11:18) 17:51:34 at Object.<anonymous> (/usr/local/lib/node_modules/migrate-mongo/node_modules/fs-extra/lib/mkdirs/index.js:3:44)