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

feat: add support for specifying path to node in settings #118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

taylorzane
Copy link

@taylorzane taylorzane commented Apr 28, 2024

This pull request adds support for specifying a path to a node binary. I've found that system can be unreliable when using tools like nodenv (even with proper .zprofile setup), so this change lets a user specify any node binary to be used with LSP plugins.

I've also submitted a PR to update the lsp_utils.sublime-settings: sublimelsp/LSP#2464

Caveat: This change assumes that an npm binary exists in the same directory as node; in my research it seems that all installations of Node.js follow this principle, so it should be a non-issue.

@predragnikolic
Copy link
Member

Hello,
Thanks for this PR.

I use nvm
and I am on a Mac.

When I have the following set in lsp_utils.sublime-settings:

{
	"nodejs_runtime": ["/Users/predrag/.nvm/versions/node/v20.11.1/bin/node"],
}

I get this error:

Unable to start subprocess for LSP-json
Traceback (most recent call last):
  File "/Users/predrag/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/server_npm_resource.py", line 123, in install_or_update
    self._node_runtime.run_install(cwd=self._server_dest)
  File "/Users/predrag/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/node_runtime.py", line 240, in run_install
    raise Exception('Failed to run npm command "{}":\n{}'.format(' '.join(args), error))
Exception: Failed to run npm command "ci --omit=dev --verbose":
env: node: No such file or directory

@taylorzane
Copy link
Author

@predragnikolic I went ahead and made the suggested changes to support nvm. I tested it locally and everything seemed to work fine. Let me know if you're still experiencing runtime errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants