4

I have this error in the console, below which gives the number 8301. What does this number mean and how can I use it to troubleshoot the error?

(node:8301) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.

Pleas note, I am using this as an example error to try and understand the printed number (node:8301). I don't need help with the error itself.

Please help me to understand node errors.

3 Answers3

1

The number portion of (node:8301) is the node process's process id (pid). This is attached to all warnings that Node.js itself emits, or that are emitted via its process.emitWarning() utility. (In the particular example in the question, the warning is from a user module using process.emitWarning().)

For what it's worth, NODE_DEBUG also logs pids in the logged information, although strangely not in that format.

I'm not sure if there is actually official documentation on this. There is presently a discussion to add a "Warnings" section to the official documentation: https://github.com/nodejs/node/issues/24987

This question was also asked to https://github.com/nodejs/node/issues/25120, where I discovered and originally answered it.

Fishrock123
  • 113
  • 2
  • 7
0

try this:

MongoClient.connect("mongodb://localhost:27017/YourDB", { useNewUrlParser: true })

from here

krudeboy
  • 9
  • 2
0

Honestly, I’ve been working in node since 2009, and I’ve never bothered to look into the error codes unless I need my software to handle the error. Mostly, I just read the error text.

In the case of your example, the error text clearly tells me what the problem is.

I’ve found generally that the quality of error messages and codes alike varies greatly on the library you’re using.

Paul
  • 35,689
  • 11
  • 93
  • 122