You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"Invalid or unexpected token" at single quotation mark #2204
but when I type node index.js, this is what I get....
Dereks-iMac:msgbot derekvann$ node index.js
/Users/derekvann/Desktop/msgbot/index.js:1
const express = require(‘express’);
^
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
on this note @bnoordhuis it would be kinda neat to display the node.js version in all node.js stacktraces, at the end. think about how much time this would save users debugging etc, and on online messsage boards.
It is possible that the quotes you have are not ' but instead are another character.
Could you try replacing the quotes (eg rewriting them or replacing with double quotes) to see whether that resolves the issue?
The quotes on all the lines look they are ’ rather than '. This is a common issue if copying from sites like Medium which can replace quotes with the "nicer looking" alternatives.
Reacted by ghnipunasaranga, Wanda Song, Ikechukwu Nigel Ogbuchi, Harsh Bhardwaj and Arun Kóttayil
Activity
ORESoftware commentedon Sep 27, 2019
you are likely using an older node.js version, whereby it doesn't recognize the
constkeyword.when you type
node -vin the terminal, what do you get?to install a newer version of node.js on a non-windows machine, I recommend NVM.
ORESoftware commentedon Sep 27, 2019
on this note @bnoordhuis it would be kinda neat to display the node.js version in all node.js stacktraces, at the end. think about how much time this would save users debugging etc, and on online messsage boards.
KitchenLedger commentedon Sep 27, 2019
I have Version 10.16.3
is that too old?
bruce-one commentedon Sep 29, 2019
That version should support
const.It is possible that the quotes you have are not
'but instead are another character.Could you try replacing the quotes (eg rewriting them or replacing with double quotes) to see whether that resolves the issue?
The quotes on all the lines look they are
’rather than'. This is a common issue if copying from sites like Medium which can replace quotes with the "nicer looking" alternatives.tniessen commentedon Oct 13, 2019
@bruce-one is right, you are using some fancy unicode quote characters instead of "normal" single-quotes. If you replace them, it should work.
[-]Help with Node Please[/-][+]"Invalid or unexpected token" at single quotation mark[/+]han-so1omon commentedon Jan 11, 2020
I am having this same error, but it only occurs when splitting a string into multiple lines. When the string is in one line the error goes away.
Error example:
Correct example:
This is using nodejs v12.13.1
tniessen commentedon Jan 11, 2020
@han-so1omon That's intentional. If you want line feeds, use the
\nescape sequence: