Skip to content

Commit a9724a5

Browse files
committed
Fetch prefix from npm prefix -g
1 parent 3e20f52 commit a9724a5

File tree

1 file changed

+7
-2
lines changed
  • python_packages/jupyter_lsp/jupyter_lsp

1 file changed

+7
-2
lines changed

python_packages/jupyter_lsp/jupyter_lsp/types.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import pathlib
77
import re
88
import shutil
9+
import subprocess
910
import sys
1011
from typing import (
1112
TYPE_CHECKING,
@@ -257,8 +258,12 @@ def _default_node_roots(self):
257258
# ... but right in %PREFIX% on nt
258259
roots += [pathlib.Path(sys.prefix)]
259260

260-
# check ~/.local/lib for user-wide installations
261-
roots += [pathlib.Path.home() / ".local" / "lib"]
261+
# check for custom npm prefix
262+
if shutil.which("npm"):
263+
prefix = subprocess.run(
264+
["npm", "prefix", "-g"], check=True, capture_output=True
265+
).stdout.decode("utf-8")
266+
roots += [pathlib.Path(prefix) / "lib"]
262267

263268
return roots
264269

0 commit comments

Comments
 (0)