gitmoji-changelog icon indicating copy to clipboard operation
gitmoji-changelog copied to clipboard

Syntax error "(" unexpected

Open SturmB opened this issue 3 years ago β€’ 12 comments

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 [email protected]: this library is no longer supported
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: 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, [email protected], fixes the issue for now; no warnings and no syntax errors.

SturmB avatar Feb 26 '21 19:02 SturmB

I have got the same problem πŸ‘

Tomas2D avatar Aug 01 '21 17:08 Tomas2D

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?

frinyvonnick avatar Aug 02 '21 07:08 frinyvonnick

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

Tomas2D avatar Aug 06 '21 13:08 Tomas2D

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)

SturmB avatar Aug 06 '21 16:08 SturmB

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

SerenModz21 avatar Aug 22 '21 10:08 SerenModz21

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

0x1026 avatar Jan 11 '22 20:01 0x1026

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

frinyvonnick avatar Jan 11 '22 21:01 frinyvonnick

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

0x1026 avatar Jan 11 '22 22:01 0x1026

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

frinyvonnick avatar Jan 12 '22 07:01 frinyvonnick

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

jpolo avatar Aug 05 '22 08:08 jpolo

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

Tomas2D avatar Feb 11 '23 15:02 Tomas2D

Still facing this issue.

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

sarangnx avatar Jan 31 '24 08:01 sarangnx