kysely / mongodb-atlas-backup

The human way to mongodump and mongorestore your MongoDB Atlas cluster
MIT License
31 stars 13 forks source link

Version of NodeJs to execute #2

Closed enzolutions closed 6 years ago

enzolutions commented 6 years ago

Hi @kysely

I tried to create a nodejs file to run your example.

But looks like the Node version I'm using v8.9.0 is not compatible with ES6 or something like that.

I got the following error

(function (exports, require, module, __filename, __dirname) { import MongoBackup from 'mongodb-atlas-backup';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:599:28)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Any suggestions, about how to execute your example in command line using node?

Thanks in advance.

kysely commented 6 years ago

Hi @enzolutions import is a statement from ES6 module syntax that is not natively supported in Node.js yet. You can either use Babel to transpile your code or use the following import instead:

const MongoBackup = require('mongodb-atlas-backup');

Please let me know if that works for you.