Sublime Forum

[SOLVED] LSP-html with local nodejs

#1

Hello everyone,

I’ve installed Sublime v4180 together with LSP and LSP-html. After opening an HTML file I get following error:


Could anyone tell me, how to make it work with preinstalled node@20 via brew on my macOS, please?
I tried couple things, for example adding [1]:

{
	"nodejs_runtime": ["local", "system"]
}

to the lsp_utils.sublime-settings but it didn’t work.

0 Likes

#2

That means your node binary cannot be found by the PATH env variable.

https://lsp.sublimetext.io/troubleshooting/#updating-the-path-used-by-lsp-servers

Though I would just suggest use a lsp_utils-managed one (i.e., just click Download Node.js). That would reduce many potential issues or questions you are going to ask.

0 Likes

#3

Thank you so much for your prompt reply and the link - I missed it somehow before.

Anyway, I added the nodejs to the $PATH (Adding path+=('/opt/homebrew/opt/node@20/bin/node') to ~/.zprofile), restarted computer and even though the Sublime loads the updated $PATH, the error is still there :confused:

startup, version: 4180 osx arm64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/sublime_text
application: /Applications/Sublime Text.app
working dir: /
packages path: /Users/koleon/Library/Application Support/Sublime Text/Packages
state path: /Users/koleon/Library/Application Support/Sublime Text/Local
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: /Users/koleon/Library/Application Support/Sublime Text/Installed Packages
ignored_packages: ["Vintage"]
pre session restore time: 0.268869
OpenGL Context Information:
  GL API Version: 4.1 Metal - 88.1
  GLSL Version: 4.10
  Vendor: Apple
  Renderer: Apple M2
startup time: 0.315426
environment variables loaded using: /bin/zsh -l
first paint time: 0.325371
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.html_print
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.keymap
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin A File Icon.plugin
reloading plugin LSP-css.data_types
reloading plugin LSP-css.plugin
reloading plugin LSP-gopls.boot
reloading plugin LSP-html.data_types
reloading plugin LSP-html.plugin
reloading plugin LSP-terraform.plugin
reloading plugin LSP-typescript.commands
reloading plugin LSP-typescript.plugin
reloading plugin LSP-typescript.plugin_types
reloading plugin LSP.boot
reloading plugin Package Control.plugin
plugins loaded
--- lsp_utils Node.js resolving start ---
Resolving Node.js Runtime in env PATH for package LSP-html...
 * Failed: "node" binary not found
Resolving Node.js Runtime from lsp_utils for package LSP-html...
 * Binaries check failed: "node" binary not found
 * Download skipped
--- lsp_utils Node.js resolving end ---
Unable to start subprocess for LSP-html
Traceback (most recent call last):
  File "/Users/koleon/Library/Application Support/Sublime Text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 257, in start_async
    if plugin_class.needs_update_or_installation():
  File "/Users/koleon/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/_client_handler/abstract_plugin.py", line 101, in needs_update_or_installation
    server = cls.get_server()
  File "/Users/koleon/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/npm_client_handler.py", line 122, in get_server
    cls.__server = ServerNpmResource.create({
  File "/Users/koleon/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/server_npm_resource.py", line 47, in create
    node_runtime = NodeRuntime.get(package_name, storage_path, required_node_version)
  File "/Users/koleon/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/node_runtime.py", line 59, in get
    cls._node_runtime = cls._resolve_node_runtime(package_name, storage_path, required_semantic_version)
  File "/Users/koleon/Library/Application Support/Sublime Text/Lib/python38/lsp_utils/node_runtime.py", line 129, in _resolve_node_runtime
    raise Exception('Failed resolving Node.js Runtime. Please check in the console for more details.')
Exception: Failed resolving Node.js Runtime. Please check in the console for more details.

Package Control: Skipping automatic upgrade, last run at 2024-08-22 11:09:11, next run at 2024-08-22 19:09:11 or after
>>> import os; os.environ["PATH"]
'/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/usr/local/go/bin:/opt/homebrew/opt/node@20/bin/node'

I know, that I could overcome it by simply installing another nodejs, but it does not make sense to me, as it’s already there.

EDIT: I solved it by changing the ~/.zprofile line to path+=('/opt/homebrew/opt/node@20/bin') as it seems, that LSP is looking for the npm as well. This comment helped: https://github.com/sublimelsp/LSP/issues/1671#issuecomment-2267524383

2 Likes