0

When I put in the code

const mongoose = require("mongoose")

I get back the following error:

 /Users/user/shares3/node_modules/mongodb/lib/utils.js:1069
        catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/user/shares3/node_modules/mongodb/lib/operations/add_user.js:6:17)

This code is as simple as could be. I have tried reinstalling the mongoose package.

Do you have any ideas on how I can troubleshoot this?

Brett
  • 3,296
  • 5
  • 29
  • 45

1 Answers1

1

The issue is caused by using a (very) old version of Node.js that doesn't support try/catch.

robertklep
  • 198,204
  • 35
  • 394
  • 381