oxc icon indicating copy to clipboard operation
oxc copied to clipboard

linter: oxc_language_server can't find node runtime (VSCode extension)

Open danecando opened this issue 1 year ago • 4 comments

What version of Oxlint are you using?

0.16.0

What command did you run?

No response

What does your .oxlintrc.json config file look like?

My system/VSCode (Latest MacOS/VSCode) seems to have trouble with the oxc_language_server script. It can't resolve the node command. I have node installed via mise-en-place. NODE_PATH is available in my login shells.

However I can't seem to get the language server to kick-off without editing the node_modules/.bin/oxc_language_server script and giving it a fully qualified path to a node runtime.

My system setup is pretty clean and simple, so I'd be really surprised if others were not running into similar issues.

The PATH's added in the script seem kind of odd - maybe it's because the linter is installed locally in my project?

node_modules/.bin/oxc_language_server

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -z "$NODE_PATH" ]; then
  export NODE_PATH="/Users/xxx/repos/xxx/node_modules/.pnpm/[email protected]/node_modules/oxlint/bin/node_modules:/Users/xxx/repos/xxx/node_modules/.pnpm/[email protected]/node_modules/oxlint/node_modules:/Users/xxx/repos/xxx/node_modules/.pnpm/[email protected]/node_modules:/Users/xxx/repos/xxx/node_modules/.pnpm/node_modules"
else
  export NODE_PATH="/Users/xxx/repos/xxx/node_modules/.pnpm/[email protected]/node_modules/oxlint/bin/node_modules:/Users/xxx/repos/xxx/node_modules/.pnpm/[email protected]/node_modules/oxlint/node_modules:/Users/xxx/repos/xxx/node_modules/.pnpm/[email protected]/node_modules:/Users/xxx/repos/xxx/node_modules/.pnpm/node_modules:$NODE_PATH"
fi
if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  "$basedir/../oxlint/bin/oxc_language_server" "$@"
else
  exec node  "$basedir/../oxlint/bin/oxc_language_server" "$@"
fi

What happened?

Output

2025-03-20 08:26:06.567 [info] [Trace - 8:26:06 AM] Sending request 'initialize - (0)'.
2025-03-20 08:26:06.603 [info] [Error - 8:26:06 AM] Server process exited with code 0.
2025-03-20 08:26:06.724 [info] /Users/xxx/repos/xxx/node_modules/.bin/oxc_language_server: line 16: exec: node: not found

2025-03-20 08:26:06.724 [info] [Error - 8:26:06 AM] Server process exited with code 127.
2025-03-20 08:26:06.725 [info] [Error - 8:26:06 AM] Server initialization failed.

Shout out

Just want to say thanks to everyone contributing to this project. Outside of having some issues getting the LSP setup this does not feel like beta software at all. The linter is incredible.

danecando avatar Mar 20 '25 12:03 danecando

Have you tried removing node_modules and reinstalling? Also, could you run node --version in the terminal to check if Node is working properly?

shulaoda avatar Mar 23 '25 01:03 shulaoda

VSCode uses a own npm version. You can check in "Help" -> "About".

My system setup is pretty clean and simple, so I'd be really surprised if others were not running into similar issues.

Yes. This is the first report that I known. I would guess your setup somehow broken.

Image

Sysix avatar Mar 27 '25 23:03 Sysix

I've never written a VSCode extension before but I did see in the source code that it looks like Node is pulled through a VSCode specific API that I couldn't seem to find much documentation on.

The node version running in VSCode is Node.js: 20.18.3 - which is different from the one running in my project 20.16.0.

I've tried deleting and reinstalling node_modules. I'm using https://mise.jdx.dev/lang/node.html to manage the node runtimes on my machine.

MacOS Sequoia 15.3.2
VSCode Version: 1.96.2

Going to try to use it on a different machine with similarish setup and see if I have the same problem

danecando avatar Mar 31 '25 12:03 danecando

i have the same issue using code-server + mise on debian

as a workaround for linux i ran: which node // or mise which node ln -s (the path from the previous command) /usr/bin/node

i also tried to fix it with export NODE_PATH but it did not work

would be nice to have an option in oxc vscode config to set manually path to the node or to use NODE_PATH if available

error logs i had before workaround: 2025-04-26 09:17:08.306 [info] [Error - 9:17:08 AM] Server initialization failed. 2025-04-26 09:17:08.306 [info] Message: write EPIPE Code: -32099 2025-04-26 09:17:08.306 [info] [Error - 9:17:08 AM] oxc client: couldn't create connection to server. 2025-04-26 09:17:08.306 [info] Message: write EPIPE Code: -32099 2025-04-26 09:17:08.307 [info] [Error - 9:17:08 AM] The oxc server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information. 2025-04-26 09:17:08.307 [info] /usr/bin/env: ‘node’: No such file or directory

aerox0 avatar Apr 26 '25 08:04 aerox0

would be nice to have an option in oxc vscode config to set manually path to the node or to use NODE_PATH if available

looks like both eslint + ts lang server have this option, i think we should support it also

Image

camc314 avatar May 06 '25 12:05 camc314

as a workaround for linux i ran: which node // or mise which node ln -s (the path from the previous command) /usr/bin/node

As a workaround for MacOS you can create a symbolic link to /usr/local/bin/node since /usr/bin is protected.

I agree that making the node path configurable would be ideal

danecando avatar May 13 '25 13:05 danecando

This will be resolved with the next release. The VSCode Extension will no longer look for node_modules language servers and always uses its own one (without JS Wrapper).

Sysix avatar May 18 '25 12:05 Sysix