frinyvonnick / gitmoji-changelog

A changelog generator for gitmoji 😜
https://www.npmjs.com/package/gitmoji-changelog
MIT License
387 stars 48 forks source link

Syntax error "(" unexpected #211

Open SturmB opened 3 years ago

SturmB commented 3 years ago

I updated npm to v7.6.0 today and now gitmoji-changelog is consistently giving me an error:

$ npx gitmoji-changelog
/home/sturm/.npm/_npx/989ebc59bfc33b01/node_modules/.bin/gitmoji-changelog: 1: Syntax error: "(" unexpected

Before this, the first time I tried to run it after upgrade npm, it asked to be installed again for some reason, then gave me several warnings:

$ npx gitmoji-changelog
Need to install the following packages:
  gitmoji-changelog
Ok to proceed? (y) y
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated core-js@2.6.12: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/home/sturm/.npm/_npx/989ebc59bfc33b01/node_modules/.bin/gitmoji-changelog: 1: Syntax error: "(" unexpected

I can confirm that this is specific to npm 7.6+ (possibly all of 7+). Downgrading back to my previous version, npm@6.14.9, fixes the issue for now; no warnings and no syntax errors.

Tomas2D commented 3 years ago

I have got the same problem πŸ‘

frinyvonnick commented 3 years ago

Hi @SturmB πŸ‘‹

Thank you for opening this issue πŸ™ I don't have npm 7.6 on my current computer to give it a try but I'll check it as soon as possible. Can you also share your node version, please?

Tomas2D commented 3 years ago

I am getting this issue with the following versions: Node: v16.6.0 NPM: 7.19.1

SturmB commented 3 years ago

So, this appears to be a bit spotty when it comes to different node/npm versions. Some of them work fine while others throw that 'Syntax error: "(" unexpected' message. For example:

[βœ”] node 14.17.4 / npm 6.14.14 (latest LTS release) [❌] node 15.11.0 / npm 7.6.0 (latest during my original post) [βœ”] node 16.2.0 / npm 7.13.0 [❌] node 16.6.1 / npm 7.20.3 (latest as of this writing)

SerenModz21 commented 2 years ago

I also have a syntax error, but I don't think its the same one, I'm using node v16.6.1 with npm v7.21.0

image

0x1026 commented 2 years ago

So, this appears to be a bit spotty when it comes to different node/npm versions. Some of them work fine while others throw that 'Syntax error: "(" unexpected' message. For example:

[βœ”] node 14.17.4 / npm 6.14.14 (latest LTS release)
[❌] node 15.11.0 / npm 7.6.0 (latest during my original post)
[βœ”] node 16.2.0 / npm 7.13.0
[❌] node 16.6.1 / npm 7.20.3 (latest as of this writing)

I just install node 16.2.0 / npm 7.13.0 and the error still persists

image

frinyvonnick commented 2 years ago

If someone is interested in investigating why it happens it could be really helpfulπŸ™

0x1026 commented 2 years ago

My question is why we use this: https://github.com/frinyvonnick/gitmoji-changelog/blob/0522b8706577743000be599f481dbdb2d2de69e5/packages/gitmoji-changelog-cli/package.json#L20-L22

Finished investigating, and came to the conclusion that it must be installed globally (npm i -g gitmoji-changelog) and requires an additional package called xsel, which can be installed with apt install xsel.

By this way, I'm getting another error: image image

frinyvonnick commented 2 years ago

We use bin because this the way to declare a cli. Here is the documentation https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

jpolo commented 2 years ago

It seems the shebang #!/usr/bin/env node at the beginning of the bin file could solve the problem...

Tomas2D commented 1 year ago

ping @frinyvonnick, I think that proposed solution from @jpolo is sufficient.

sarangnx commented 6 months ago

Still facing this issue.

node: v18.17.1 npm: v9.6.7 gitmoji-changelog: v2.3.0

petrKavulok commented 2 months ago

Was getting the same issue after updating node to v20.7.0, npm i -g gitmoji-changelog solved it for me.