Error inside node module

I used the fix where I ran rm package-lock.json & npm install --legacy--something...
and I’m still getting this error:


Now it’s an error inside some node module & I don’t think tampering with external packages would be good…
Please let me know if there’s some work around for this issue!

try removing “node_modules” folder and “package-lock.json” and try again!

if not, try deleting everything and start fresh but use that legacy flag on the step of “npm install”?

Thanks for the reply but that won’t work either… I know since I tried!
I’ve been through some previous cases related to the same error & I rectified it. :v:
Check the post below :arrow_heading_down:

post the version of node and npm you are using. there is the possibility you are using a recent one and a package is not fully compatible.

I tried with node v18.0.0 and npm version 8.6.0 and found no problem except the possibility related to .env file

I tried with no environment file and then non valid url in it. every error coming from uri_parser.js is changed and then solved by changing “MFLIX_DB_URI”. when its format is acceptable but address is wrong then you will get (I just changed the defult env file to have @a.b.com)

Error: querySrv ENOTFOUND _mongodb._tcp.a.b.com
    at QueryReqWrap.onresolve [as oncomplete] (node:dns:255:19)

this means you need to renew your .env file, from scratch if needed, editing by hand instead of copy-pasting. there might be an invisible character slipped into.

I use node version 16.13.0 LTS with npm version 8.10.0.
The code runs w/o any error since then. You’ll come across a message that ask you to set useUnifiedTopology to true while connecting to the database.

I am confused if you could finish the course or are still stuck somewhere. also “useUnifiedTopology” seems to be related to server discovery but I will not even pretend to know more :slight_smile:

I was curious and checked the source code. Although it is still related to URI, the error you get can result in only one place and I couldn’t imagine how one could even trigger it (you did :stuck_out_tongue: ).

  if (cap[4].split('?')[0].indexOf('@') !== -1) {
    return callback(new MongoParseError('Unescaped slash in userinfo section'));
  }

the following are used to parse the URI, and cap[4] is the db?query part of it. you can try them in the REPL.

const HOSTS_RX = /(mongodb(?:\+srv|)):\/\/(?: (?:[^:]*) (?: : ([^@]*) )? @ )?([^/?]*)(?:\/|)(.*)/;
let uri=mongodb+srv://user:pwd@host/db?query
let cap=uri.match(HOSTS_RX)

the error is triggered if it has a similar form to this: mongodb+srv://user:pwd@host/why@here?query.
if the part after host and before query has “@” sign, for whatever the reason, it triggers this error.

Anyways, if the error is gone and you continue to the course, you somehow fixed the URL without knowing.