Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error "(" unexpected #211

Open
SturmB opened this issue Feb 26, 2021 · 12 comments
Open

Syntax error "(" unexpected #211

SturmB opened this issue Feb 26, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@SturmB
Copy link

SturmB commented Feb 26, 2021

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.

@Tomas2D
Copy link

Tomas2D commented Aug 1, 2021

I have got the same problem 👍

@frinyvonnick frinyvonnick added the bug Something isn't working label Aug 2, 2021
@frinyvonnick
Copy link
Owner

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
Copy link

Tomas2D commented Aug 6, 2021

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

@SturmB
Copy link
Author

SturmB commented Aug 6, 2021

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
Copy link

SerenModz21 commented Aug 22, 2021

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
Copy link

0x1026 commented Jan 11, 2022

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
Copy link
Owner

If someone is interested in investigating why it happens it could be really helpful🙏

@0x1026
Copy link

0x1026 commented Jan 11, 2022

My question is why we use this:

"bin": {
"gitmoji-changelog": "./src/index.js"
},

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
Copy link
Owner

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
Copy link

jpolo commented Aug 5, 2022

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

@Tomas2D
Copy link

Tomas2D commented Feb 11, 2023

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

@sarangnx
Copy link

Still facing this issue.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants