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

Could not determine npm prefix: [WinError 2] The system cannot find the file specified #1004

Closed
JulianSMoore opened this issue Oct 20, 2023 · 7 comments

Comments

@JulianSMoore
Copy link

I'm not a dev so I hope the following suffices to be useful:

Windows 10
IPython : 8.16.1
ipykernel : 6.25.2
ipywidgets : 8.1.1
jupyter_client : 8.4.0
jupyter_core : 5.4.0
jupyter_server : 2.8.0
jupyterlab : 4.0.7
nbclient : 0.8.0
nbconvert : 7.9.2
nbformat : 5.9.2
notebook : not installed
qtconsole : not installed
traitlets : 5.11.2

with jupyterlab-lsp==5.0.0 jupyter-lsp==2.2.0 python-lsp-server[all]

on startup, the console kept saying "Could not determine npm prefix: [WinError 2] The system cannot find the file specified"

It's not that npm is missing, it's because WIndows isn't Linux; see here

I resolved the problem for myself: in C:\Users\Julian\anaconda3\envs\PlainPY\Lib\site-packages\jupyter_lsp\types.py

In the class LanguageServerManagerAPI, change _npm_prefix to be

def _npm_prefix(self):
    try:
        return (
            subprocess.run(["npm.cmd", "prefix", "-g"], check=True, capture_output=True)
            .stdout.decode("utf-8")
            .strip()
        )
    except Exception as e:  # pragma: no cover
        self.log.warn(f"Could not determine npm prefix: {e}")

i.e. add ".cmd" to npm: the error wasn't saying the prefix couldn't be found, but rather it couldn't invoke npm in the first place,

Obviously that's not a fix for everyone, it's windows specific.

@krassowski
Copy link
Member

I believe this should be solved with #955 which will be available in the next jupyter-lsp version.

@JulianSMoore
Copy link
Author

Great. Strange that that issue wasn't obvious when I googled it first, but still -- great. Thx.

@waysbg
Copy link

waysbg commented Apr 16, 2024

**JulianSMoore ** commented

Tnks man, it helped, i mean adding .cmd to this part ....["npm.cmd", "prefix", "-g"].... as you have explained.
Tnks!!!

@WKQ9411
Copy link

WKQ9411 commented Apr 19, 2024

Thanks for the solution, it really works!

@SpezialK71
Copy link

This fixed an annoying issue I'd been having for months.

Thanks!

@ygwang1
Copy link

ygwang1 commented Sep 6, 2024

Thanks!!!

1 similar comment
@jtyoui
Copy link

jtyoui commented Dec 6, 2024

Thanks!!!

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

No branches or pull requests

7 participants