Error encountered: YouCompleteMe is unable to locate the necessary executable 'npm' for the installation of TSServer

While attempting to install YouCompleteMe for vim and enable support for Java and Javascript, I followed the instructions provided here. My command was:

sudo /usr/bin/python3.6 ./install.py  --java-completer --ts-completer

Unfortunately, I encountered an error message during the installation process:

...
[100%] Linking C shared library /home/vagrant/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/cregex/regex_3/_regex.so
[100%] Built target _regex
Downloading jdt.ls from http://download.eclipse.org/jdtls/snapshots/jdt-language-server-0.54.0-202004152304.tar.gz...
Extracting jdt.ls to /home/vagrant/.vim/bundle/YouCompleteMe/third_party/ycmd/third_party/eclipse.jdt.ls/target/repository...
Done installing jdt.ls
ERROR: Unable to find executable 'npm'. npm is required to install TSServer.

The strange part is that npm is already in my PATH as confirmed by the following commands:

=> npm -v
6.13.4
=> which npm
/home/vagrant/.nvm/versions/node/v8.17.0/bin/npm

Any insights into why the installation of YouCompleteMe with ts-completer support is failing?

Answer №1

Can someone help figure out why YouCompleteMe isn't installing properly with ts-completer support?

If you're experiencing installation failures, it might be because you're running the install.py script as sudo and the location where nvm installs node is not included in the secure_path. The secure_path is utilized when a script runs with sudo permissions.

You can compare the contents of PATH and secure_path by executing the following commands:

$ echo 'echo $PATH' | sudo sh    # secure_path
$ echo 'echo $PATH' | sh         # your user PATH

To verify that sudo does not have npm in its path, run these commands:

$ which npm
$ sudo which npm

What's the solution?

One approach is to execute the script without using sudo like this:

/usr/bin/python3.6 ./install.py --java-completer --ts-completer

Another option is to copy the contents of nvm bin to one of the secure_path locations such as /usr/local/bin.

$ find $(which npm | xargs dirname) -type l -o -type f | sudo xargs cp -t /usr/local/bin

# test
$ sudo npm -v
$ sudo node -v

After completing these steps, the installer should be able to locate npm.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips on creating type definitions for CSS modules in Parcel?

As someone who is brand new to Parcel, I have a question that may seem naive. In my project, I am using typescript, react, less, and parcel. I am encountering an error with typescript stating 'Cannot find module 'xxx' or its corresponding t ...

The error message "SyntaxError: Cannot use import statement outside a module" popped up while working with discord.js, typescript, heroku

// Necessary imports for running the discord bot smoothly import DiscordJS, { TextChannel, Intents, Message, Channel, NewsChannel, ThreadChannel, DiscordAPIError } from 'discord.js' type guildTextBasedChannel = TextChannel | NewsChannel | ThreadC ...

Is it necessary to run "npm init" before installing packages with npm, or can I do it afterwards too?

While I understand that I can still run the node.js app without using npm init and going straight to installation, it is considered a good practice. However, if I happen to forget to run npm init initially, what steps can I take to enhance my application? ...

TypeScript: Defining a custom object type using an array of objects

Is there a way to dynamically generate an object based on the name values in an array of objects? interface TypeA { name: string; value: number; } interface TypeB { [key: string]: { value: any }; } // How can we create an OutputType without hard ...

Obtaining specific information about the target item that a source item was dropped on (using ng2-dragula in Angular)

Issue: I need assistance in implementing the following functionality using the ng2-dragula drag behavior. I am working on creating a feature similar to the app-launcher found on iOS and Android devices. I aim to drag an item A and drop it onto anothe ...

Is there a method of converting React components into strings for manipulation?

In my React TypeScript project, I am utilizing a crucial library that contains a component which transforms text into SVG. Let's refer to this library component as <LibraryRenderer />. To enhance the functionality, I have enclosed this componen ...

Ways to verify the functionality of a function utilizing a Subscription that yields no return value

I'm working with a TypeScript ModelService that has an edit function: edit(model: Model): Observable<Model> { const body = JSON.stringify(model); return this.http.put(`/models/edit/${model.id}`, body)); } Additionally, there is a TypeScrip ...

Updating npm dependencies with unmet peer requirements

Having trouble updating react-router-dom, encountering an ERR with the error message ERESOLVE unable to resolve dependency tree. Attempting to update using the command: npm update "popper.js" "bootstrap" "react-router-dom" Could not resolve dependency: np ...

To set up Express on a Windows 7 system, utilize the npm install command

I have encountered an error message while trying to install npm modules, most likely due to being behind a network proxy. Can someone please advise me on how to resolve this issue? D:\NodeMVA-master\NodeMVA-master\07_BasicExpress>npm ins ...

Troubleshooting Image Upload Problem with Angular, Node.js, Express, and Multer

While trying to implement the functionality of uploading an image, I have been referencing various guides like how to upload image file and display using express nodejs and NodeJS Multer is not working. However, I am facing issues with getting the image to ...

What could be the reason for encountering an error during npm installation?

Having trouble installing npm as it keeps showing errors and files are failing to download. I attempted to install it on various platforms such as gitpod, codespaces, and VS Code but encountered the same issue every time. Kindly assist me in downloading np ...

Mixing TypeScript generic types loosely

Let's explore a simple example of typescript mixins: import { Observable, of } from 'rxjs'; class Service<TDataType> { public foo(f: TDataType): Observable<TDataType> { return of(f); } } type GConstructor<T = {}> = new ...

The orderBy filter seems to be malfunctioning

I'm utilizing ngx-pipes from this webpage: https://www.npmjs.com/package/ngx-pipes#orderby Specifically, I am using the orderBy pipe. However, when I implement the orderBy pipe in my HTML, the information is not being ordered correctly (from minor t ...

Tips for troubleshooting Angular 4 unit testing using jasmine and karma with simulated HTTP post requests

I have a service that I need to unit test in Angular 4 using TypeScript and Jasmine. The problem is with the http where it needs to perform a post request and get an identity in return, but for some reason, no data is being sent through. My goal is to ac ...

Exploring the Differences Between Native Script and Ionic: A Guide to Choosing the Right Framework for Your Hybrid Apps

When deciding between Ionic and Native Script for hybrid app development, which technology would you recommend? Or do you have another suggestion knowing that I am familiar with Angular 6? Also, I am looking for a Native Script tutorial, preferably in vide ...

Need help with npm installation woes? In search of tips on ensuring version compatibility for Angular V16?

I've been facing numerous challenges with npm installation recently and could really use some guidance. Whenever I attempt to execute npm install, I consistently encounter version compatibility errors that disrupt my development process. It's bec ...

Navigating in Angular with parameters without modifying the URL address

In a nutshell, my goal is to navigate to a page with parameters without showing them in the URL. I have two components: Component A and B. What I want to do is route to B while still needing some parameters from A. I know I can achieve this by setting a ...

Beginner's Guide: Building your debut JavaScript/TypeScript library on GitHub and npm

I am looking to develop a simple JavaScript/TypeScript library focused on color conversion. Some of the functions and types I aim to export include: export type HEX = string; export type RGB = { r: number; g: number; b: number }; export type RGBA = { r: n ...

Introduce a specialized hierarchical data structure known as a nested Record type, which progressively ref

In my system, the permissions are defined as an array of strings: const stringVals = [ 'create:user', 'update:user', 'delete:user', 'create:document', 'update:document', 'delete:document&ap ...

Can you please provide guidance on setting the return type to React.StatelessComponent?

This code is functioning correctly: import * as React from 'react'; export default (props: any): JSX.Element => { return ( <h1>{props.children}</h1> ) } However, this snippet is causing an error: import * as React from ...