getspooky/create-express-app

Unexpected identifier error

Closed this issue · 3 comments

Whenever I try to start my server, I get an "Unexpected identifier" error. A screenshot is attached.

image

When using WSL, however, a different error occurs.

image

I'm using the ES6 template.

Ok, I got it. The template supports ES6 modules, but the express-artisan package doesn't.

To fix that, my solution was to add the esm package and use it on the express-artisan module, like this:

// node_modules/express-artisan/index.js
[...]

require = require('esm')(module);

require('./expressArtisan');

The ESM package will allow every Node.js version to support ES6 modules, including those who don't support them natively (<13.12.0).

Everything's working perfectly now. I tested it with the other templates and they're working fine. If you want, I can make a PR with my fix, but I don't know if this is a general issue or if this is happening only on my PC.

Hi @pedrowindisch
The bug is fixed

Thanks @getspooky! Everything's working as expected now 👍