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

SyntaxError: missing ) after argument list #250

Closed
juangiordana opened this issue Feb 18, 2022 · 7 comments
Closed

SyntaxError: missing ) after argument list #250

juangiordana opened this issue Feb 18, 2022 · 7 comments
Assignees

Comments

@juangiordana
Copy link

Explain the Issue and Expected Behavior

Plugin fails because of the provided/suggested path points to a bash wrapper script instead to bin-prettier.js.

------------------
 JsPrettier ERROR 
------------------

Prettier reported the following output:

/home/juan/.nvm/versions/node/v17.5.0/bin/prettier:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
          ^^^^^^^

SyntaxError: missing ) after argument list
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1026:15)
    at Module._compile (node:internal/modules/cjs/loader:1061:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47

Node.js v17.5.0


Prettier process finished with exit code 1.

Setting prettier_cli_path to bin-prettier.js fixes the issue.

  "prettier_cli_path": "$HOME/.nvm/current/pnpm-global/5/node_modules/.pnpm/prettier@2.5.1/node_modules/prettier/bin-prettier.js",

While investigating the issue I've found the SublimeLinter-eslint plugin uses a wrapper script as well and does not have this issue.

Prettier version

To show the currently installed prettier version, run the following command:

$ prettier --version
2.5.1

JsPrettier Plug-in Version

The JsPrettier Sublime Text Plug-in version is located in the package.json file.

...
"name": "sublime-js-prettier",
"version": "1.50.1",
...

Platform Details

Provide your Sublime Text version and Platform details.

Example

- Sublime Text Version: 4
- Sublime Text Build: 4126
- Sublime Text Architecture: x64
- Operating System Name: Linux Mint
- Operating System Version: 20.3
- Operating System Architecture: x64

The contents of your User/JsPrettier.sublime-settings file

// Settings in here override those in "/JsPrettier/JsPrettier.sublime-settings",

{
  // This fails
  // "prettier_cli_path": "$HOME/.nvm/current/bin/prettier",
  // This works as expected.
  "prettier_cli_path": "$HOME/.nvm/current/pnpm-global/5/node_modules/.pnpm/prettier@2.5.1/node_modules/prettier/bin-prettier.js",
  "node_path": "$HOME/.nvm/current/bin/node"
}
@juangiordana
Copy link
Author

The issue was fixed by moving NVM loader script from .bashrc to .profile.

By doing that, this package works out of the box.

@IPWright83
Copy link

@juangiordana I'm getting the same, I thought I'd followed your suggestion but it's not helped. Could you share the contents of your .profile file (at least the changes made)?

I moved the following from my .bashrc file to my .profile file, restarted my machine but I've got the same problem you originally mentioned still:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

@juangiordana
Copy link
Author

juangiordana commented Mar 8, 2022

@IPWright83 try starting the editor from a terminal:

# Just to check, you should see the the path to Node in there.
# i.e. ~/.nvm/versions/node/v17.6.0/bin
echo $PATH

cd path-to-project
subl .

If you get your environment correct in your terminal sublime should be able to pick the variables right.

Though it was working OK for a few days, suddenly it was like if the environment variables got wiped out.

I'm not sure why that is, if its misconfiguration on my side, the fact that I could have opened a new editor window from a terminal, or who knows.

@IPWright83
Copy link

@juangiordana after reading you're issue a bit more I went down setting the prettier_cli_path path to "/home/ian/.nvm/versions/node/v16.14.0/bin/prettier" which fixes things for me.

I found moving the nvm bits from .bashrc to .profile also prevented nvm working on the terminal :/

@juangiordana
Copy link
Author

@juangiordana after reading you're issue a bit more I went down setting the prettier_cli_path path to "/home/ian/.nvm/versions/node/v16.14.0/bin/prettier" which fixes things for me.

Yeah, I find quite annoying having to set node_path for every Node related plugin I want. That's why I prefer launching the editor from the terminal and don't worry about configurations.

I found moving the nvm bits from .bashrc to .profile also prevented nvm working on the terminal :/

Yeah, there is something messing with the environment variables, but I couldn't figure out what it was.

@IPWright83
Copy link

👍🏻 Thanks for the help @juangiordana

@github-actions
Copy link

github-actions bot commented Jul 7, 2022

This issue has been automatically locked due to inactivity. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants