0

I habe the following line of code in my js file:

const { connectDb } = require("./db");

When I run nodejs locally everthing is fine and I dont get an error.

Im using v10.16.0 locally. When I put that on a server, I got the follwoing error:

2019-07-23 15:49:36.925754500 const { connectDb } = require("./db");
2019-07-23 15:49:36.925779500       ^
2019-07-23 15:49:36.930604500 SyntaxError: Unexpected token {
2019-07-23 15:49:36.930606500     at Module._compile (module.js:439:25)
2019-07-23 15:49:36.930607500     at Object.Module._extensions..js (module.js:474:10)
2019-07-23 15:49:36.930608500     at Module.load (module.js:356:32)
2019-07-23 15:49:36.930609500     at Function.Module._load (module.js:312:12)
2019-07-23 15:49:36.930610500     at Function.Module.runMain (module.js:497:10)
2019-07-23 15:49:36.930611500     at startup (node.js:119:16)
2019-07-23 15:49:36.930612500     at node.js:945:3

I'm running Version v0.10.43 on that server. What am I doing wrong?

selbolder
  • 487
  • 5
  • 22

1 Answers1

3

I'm running Version v0.10.43 on that server. What am I doing wrong?

You're running v0.10.43.

Is it too old to support destructuring (which was added in 6.0.0 … which is also past end of life!).

You could replace it with:

const connectDb = require("./db").connectDb

… but are likely to run into other problems down the line.

v0.10.43 is from 2013. It is over half a decade old. It is past the end of life. It is not supported. It does not get security releases. Don't use it.

Use a supported version instead.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335