Created
November 11, 2023 13:12
-
-
Save andy0130tw/8377e7f7f4e36d1c231001271e166e24 to your computer and use it in GitHub Desktop.
Sublime Text LSP patch for the "correct" Node path handling in lsp_utils; useful if you use nvm/volta/...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- node_runtime.py.orig 2023-11-11 21:03:31 | |
+++ node_runtime.py 2023-11-11 21:03:08 | |
@@ -217,26 +217,27 @@ | |
print('[lsp_utils] START output of command: "{}"'.format(' '.join(args))) | |
print(stdout) | |
print('[lsp_utils] Command output END') | |
if error is not None: | |
raise Exception('Failed to run npm command "{}":\n{}'.format(' '.join(args), error)) | |
def npm_command(self) -> List[str]: | |
if self._npm is None: | |
raise Exception('Npm command not initialized') | |
- return [self._npm] | |
+ return [self._node, self._npm] | |
class NodeRuntimePATH(NodeRuntime): | |
def __init__(self) -> None: | |
super().__init__() | |
- self._node = shutil.which('node') | |
- self._npm = shutil.which('npm') | |
+ print('Warning: Using hardcoded node/npm path...') | |
+ self._node = os.path.expanduser('~/.volta/bin/node') | |
+ self._npm = os.path.expanduser('~/.volta/tools/image/npm/9.9.0/bin/npm-cli.js') | |
class NodeRuntimeLocal(NodeRuntime): | |
def __init__(self, base_dir: str, node_version: str = NODE_RUNTIME_VERSION): | |
super().__init__() | |
self._base_dir = path.abspath(path.join(base_dir, node_version)) | |
self._node_version = node_version | |
self._node_dir = path.join(self._base_dir, 'node') | |
self._install_in_progress_marker_file = path.join(self._base_dir, '.installing') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment