I wanted to host my nodejs API but when I ran it for the first time I had this error:
import debug from 'debug';
^^^^^
SyntaxError: Unexpected identifier
It doesn’t appear when I run it locally (with node v16.0.0).
Usually, when we have this issue we have to upgrade node. So what I tried to do is to add: "engines": { "node": "15.x" },
In my package.json.
But it didn’t solve my issue. (I’ve also tried with 12.x and 14.x).
Hi, the highest node version glitch supports is 14.x, so best to stick with that.
Is the file that this code is in a .mjs file, or do you have "type": "module" in your package.json? If neither of these are the case, it won’t work.
If you’ve got everything set up correctly, it should all work ¯\_(ツ)_/¯
Seriously best not to “just guess” but rather to determine what is wrong. Even if a version 15 of Node seemed to work it wouldn’t have been the cause.
Are you following an example for using this library? I switch back and forth on the ES6 syntax but it appears that Debug is a class and should be import Debug from ‘debug’. Then you initialize a debug instance from it.
Hi @bricefriha - I’d love to see better why this is happening on Glitch. Could you email support@glitch.com with the name of the project so I can take a look and see if this is a bug on our end? In your email, say that Jenn sent you!