syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

Fails to install `ts-ls` #16046

Closed OZoneGuy closed 1 year ago

OZoneGuy commented 1 year ago

Description :octocat:

Typescript LSP fails to installs on a fresh spacemacs install.

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: Returns with the error:

Unable to install typescript via `npm' because it is not present

And produces the following messages:

LSP :: Download ts-ls started.
LSP :: Server ts-ls install process failed with the following error message: Unable to find a way to install typescript.
Check `*lsp-install*' and `*lsp-log*' buffer.

Expected behaviour: :heart: :smile: Install the LSP without any issues

System Info :computer:

NOTE :eyes:

I am using nvm with fish shell. The locations for the nvm data is different than other posix shells. I added the nvm environment variables to .spacemacs.env.

nvm_data=/home/omar/.local/share/nvm
nvm_mirror=https://nodejs.org/dist

I couldn't find information on this issue. If someone knows a workaround or a solution, let me know. Thanks.

MaxIDgis commented 1 year ago

Can you run npm --version in a terminal? If not, you may not have node.js installed. Node.js is used to install both typescript and ts-ls, so you'll need to install it first if you don't already have it.

OZoneGuy commented 1 year ago
npm --version
9.6.7

And here are the global packages:

npm list -g
/home/omar/.local/share/nvm/v20.3.0/lib
├── @volar/vue-language-server@1.6.5
├── corepack@0.18.0
├── eslint@8.43.0
├── npm@9.6.7
├── prettier@2.8.8
├── typescript-formatter@7.2.2
├── typescript-language-server@3.3.2
└── typescript@5.1.3

npm and node are installed via nvm. And Emacs can use that npm install, it is the only install in the system.

Now, it is not detecting npm nor node. Even though they are installed and running on the system

which node
/home/omar/.local/share/nvm/v20.3.0/bin/node

Is there a config that I am missing?

OZoneGuy commented 1 year ago

Last resort. Set the environment variable for the default node version, then reinstalled spacemacs. That solved it.

Not entirely sure what was going on.

tko commented 1 year ago

Sounds like the PATH variable in .spacemacs.env was missing the path to npm and so it was not found from within emacs. Reinstalling may've recreated .spacemacs.env with an updated PATH

komali2 commented 1 year ago

If you have this issue and suspect it's because you installed node on your system via NPM, this fixed it for me:

Edit ~/.spacemacs.env

Add your nvm directory to the PATH environment variable in ~/.spacemacs.env

It's probably like

/home/USERNAME/.nvm/versions/node/v18.17.0/bin

You can find out your specific version by doing echo $PATH and seeing what your nvm path looks like

am-p commented 3 months ago

Last resort. Set the environment variable for the default node version, then reinstalled spacemacs. That solved it.

Not entirely sure what was going on.

How do you do that? Because I use fish also and jorge Bucaramn nvm/fish