I am trying to clone an entire database from the mongosh command line in Mongo Compass using mongodump command, but this results in an unexpected error related to nodejs.
When I run:
mongodump --db=DATABASE_NAME --archive=- | mongorestore --nsFrom="OLD_DATABASE" --nsTo="NEW_DATABASE" --archive=-
I get the following error:
Error: clone(t={}){const r=t.loc||{};return e({loc:new Position("line"in r?r.line:this.loc.line,"column"in r?r.column:...\<omitted\>...)} could not be cloned.
at Object.serialize (node:v8:332:7)
at u (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:594983)
at postMessage (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:595591)
at i (/Applications/MongoDB Compass.app/Contents/Resources/app.asar.unpacked/node_modules/@mongosh/node-runtime-worker-thread/dist/worker-runtime.js:1917:600488)
Does anyone know what this error means?
This command should be run from the CLI and not within the mongo shell, then it should work all good.