Skip to content
This repository has been archived by the owner on Oct 16, 2021. It is now read-only.

Supporting yarn #167

Open
ssbanerje opened this issue Sep 16, 2021 · 12 comments
Open

Supporting yarn #167

ssbanerje opened this issue Sep 16, 2021 · 12 comments

Comments

@ssbanerje
Copy link

Is there any way to configure the install scripts to use yarn rather than npm?

It seems like currently the install script using npm is hard-coded for almost every language server.

@derektata
Copy link
Contributor

Yes, this can be done.

Example:

! test -f package.json && yarn init -y --scope=lspinstall || true
yarn add bash-language-server@latest

You just need to substitute install with add

@ssbanerje
Copy link
Author

Well this would have to be done in every lsp install script?

@derektata
Copy link
Contributor

derektata commented Sep 29, 2021

AFAIK, the yaml install script was written with yarn in mind.

Maybe we could have the system check for npm or yarn prior to running the install script, and implement logic from there.

@kabouzeid
Copy link
Owner

what would be the benefit?

@derektata
Copy link
Contributor

derektata commented Sep 29, 2021

I've been thinking about it for the past few hours, and it's kind of redundant to do this. Part being that yarn is typically installed via npm on non-Unix systems. It would also make the install part of the script a little longer doing the system checks for either command.

@ssbanerje
Copy link
Author

ssbanerje commented Sep 29, 2021

Well...

The benefit will be that there is a faster install on systems with Yarn.

Also if the systems only have Yarn and not NPM, then the whole plugin fails.

@derektata I am not sure about non-UNIX systems, but I know that it can be common to install only yarn on Linux based systems. I guess it eventually comes down to a users preference. But the whole plugin should not stop working because of that.

I have been using coc and recently moved to the builtin lsp. There it checks which pkg manager is installed and uses which ever it finds.

@kabouzeid
Copy link
Owner

npm is almost always installed when yarn is installed. I haven't noticed faster install times when installing a single package.

@derektata
Copy link
Contributor

@kabouzeid, I can understand where @ssbanerje is coming from when it comes to only having one installed.

So I have an idea

  if [ ! -x $NPM ] && [ ! -x $YARN ]; then
    # if npm and yarn are not on the system
    printf "\nCan't find npm or yarn on the system\n"
  elif [ ! -x $NPM ]; then
    # if npm is not on the system
    printf "\nNpm not found..."
    # run yarn script
  elif [ ! -x $YARN ]; then
    # if yarn is not on the system
    printf "\nYarn not found..."
    # run npm script
  fi

@derektata
Copy link
Contributor

Okay so after testing this code, I'm running into node versioning incompatibilities when using yarn, but that doesn't seem to be a problem when using npm.

recording

@ssbanerje
Copy link
Author

ssbanerje commented Sep 29, 2021

@derektata That can be an annoying problem to fix! But it is really interesting that npm is not doing this check given its in the package file (https://github.com/angular/vscode-ng-language-service/blob/3014713e18398fbec4773686d989ad11d48f2952/server/package.json#L11-L13).

@kabouzeid Yeah. I think it is a yarn 1.x vs 2.x thing. Yarn would provide deb/apk for previous releases. I think the latest release uses NPM.

@derektata
Copy link
Contributor

@ssbanerje I'll look into this more tomorrow, I just leveled up and enjoying a day off 🎂

@derektata
Copy link
Contributor

@ssbanerje Good news, I found a fix for this, and I'll be submitting a pull request in a little while with the updated code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants