Taco22
Taco22

Reputation: 123

MongoDB Illegal character driving me nuts

MongoDB is giving me [js] SyntaxError: illegal character @(shell):2:5

when writing


> db.createUser({
... user:¨brad¨,
... pwd:¨1234¨,
... roles: [ ¨readWrite¨, ¨dbAdmin¨]
... });

I know it has something to do with the colon, but anything seems to fix it.

I run it on mac if it gives any help.

Thanks in advance!

Upvotes: 1

Views: 1050

Answers (2)

geekbro
geekbro

Reputation: 1323

I had a similar issue, tried different tricks and finally was able to fix it. Don't forget to try tilt(`) instead of double quotes(") or single quotes(') in case none of this worked for you. Happy coding!!!!

Upvotes: 1

moltarze
moltarze

Reputation: 1501

I'm not sure what's going on with the weird quote character, but just use the standard quote character (" instead of ¨):

> db.createUser({
... user:"brad",
... pwd:"1234",
... roles: [ "readWrite", "dbAdmin"]
... });

It seems like the JS engine doesn't recognize U+0308 as a quote character.

Edit: After looking it up, it's not a quote - it's two dots intended to be horizontally aligned over other characters.

Upvotes: 2

Related Questions