gitmoji-changelog
gitmoji-changelog copied to clipboard
Syntax error "(" unexpected
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.
I have got the same problem π
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?
I am getting this issue with the following versions: Node: v16.6.0 NPM: 7.19.1
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 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
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
If someone is interested in investigating why it happens it could be really helpfulπ
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:
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
It seems the shebang #!/usr/bin/env node
at the beginning of the bin file could solve the problem...
ping @frinyvonnick, I think that proposed solution from @jpolo is sufficient.
Still facing this issue.
node: v18.17.1
npm: v9.6.7
gitmoji-changelog: v2.3.0