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

[BREAK CHANGE] Use npm instead of yarn for extensions #916

Closed
chemzqm opened this issue Jun 26, 2019 · 25 comments
Closed

[BREAK CHANGE] Use npm instead of yarn for extensions #916

chemzqm opened this issue Jun 26, 2019 · 25 comments

Comments

@chemzqm
Copy link
Member

chemzqm commented Jun 26, 2019

Like VSCode, most extensions have been bundled by webpack, so no need for install dependencies most of the time.

New logic will make node_modules contains extension's folder only, which means extensions works independently.

Yarn is not required for coc extensions, npm or yarn in $PATH will work by default, or use "npm.binPath" configuration for configure the path of npm or yarn.

Functions coc#util#yarn_cmd and coc#util#build are removed.

No change with commands.

@chemzqm chemzqm pinned this issue Jun 26, 2019
@chemzqm
Copy link
Member Author

chemzqm commented Jun 26, 2019

Update when npm not found in $PATH, it will use yarn.

@cvlmtg
Copy link

cvlmtg commented Jun 29, 2019

Hi, since npm is full of bugs I'd like to continue using yarn, but if I change npm.binPath it doesn't work. I've tried to set it to "yarn" and to the full path of yarn, but I keep getting the same error:

Schermata 2019-06-29 alle 07 40 36

So I decided to try to reinstall extensions from scratch. I erased ~/.config/coc and run :CocInstall coc-eslint but it doesn't work:

Schermata 2019-06-29 alle 07 44 42

@chemzqm
Copy link
Member Author

chemzqm commented Jun 29, 2019

@cvlmtg should be fixed on master.

@cvlmtg
Copy link

cvlmtg commented Jun 29, 2019

yes it works now, thanks

@nghialm269
Copy link

I get these errors when running :CocUpdate, is this normal?

image

@chemzqm
Copy link
Member Author

chemzqm commented Jul 2, 2019

@mnrce looks like you have a broken npm in your $PATH which doesn't support npm view

@nghialm269
Copy link

@chemzqm I can run the command normally in shell:
image

@chemzqm
Copy link
Member Author

chemzqm commented Jul 2, 2019

No idea, possible network error.
Consider use yarn instead.

@hamza0867
Copy link

Hi @chemzqm when I use yarn I get the error:

[coc.nvim] Install https://github.com/andys8/vscode-jest-snippets.git#master error: exited with 1 Error: Command failed: /home/hamza/.yarn/bin/yarn install https://github.com/andys8/vscode-jest-snippets.git#master --global-style --ignore-scripts --no-bin-links --no-package-lock --production --no-audit warning package.json: No license field

error install has been replaced with add to add new dependencies. Run "yarn add https://github.com/andys8/vscode-jest-snippets.git#master" instead. warning package.json: No license field

error install has been replaced with add to add new dependencies. Run "yarn add https://github.com/andys8/vscode-jest-snippets.git#master" instead.

I only get the error when trying to install a github repo directly.

It works as expected when installing something like coc-css, coc-vetur ... etc

@chemzqm
Copy link
Member Author

chemzqm commented Jul 4, 2019

@hamza0867 you have to upgrade to latest release branch and use https://github.com/andys8/vscode-jest-snippets as extension id.

@hamza0867
Copy link

@chemzqm Thank you so much man for everything you are giving this community <3

@nghialm269
Copy link

No idea, possible network error.

I tested on my home and work network though, still got same error.

Consider use yarn instead.

I can't update or install new coc extension anymore even after having switched to yarn:
image

I can run the command normally in shell:
image

I will test on my other machine next week.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 12, 2019

@mnrce looks resolved yarn is wrong, try use yarnpkg as "npm.binPath"

@nghialm269
Copy link

@mnrce looks resolved yarn is wrong, try use yarnpkg as "npm.binPath"

image
I still get that error. Is there any way I can debug this? I never debug js code before.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 12, 2019

It's not bug of javascript I think, it's bug of your yarn command, you can use npm or cnpm instead.

@nghialm269
Copy link

It's not bug of javascript I think, it's bug of your yarn command, you can use npm or cnpm instead.

I also got error when using npm as commented before, that's why I'm testing yarn.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 12, 2019

What is /snap/bin/npm on your system?

@nghialm269
Copy link

What is /snap/bin/npm on your system?

it's the npm come with node snap package

But I don't think this is a snap issue though. IIRC, my archlinux home laptop also gets this error (node is installed via pacman), I don't have that laptop with me now so I can't check.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 12, 2019

Try create javascript file:

const { exec } = require('child_process');
exec('yarn info coc-tabnine engines.coc --json', (err, stdout, stderr) => {
  if (err) {
    console.error(err);
    return;
  }
  console.log(stdout);
});

run it by node tmp.js

@nghialm269
Copy link

Try create javascript file:

const { exec } = require('child_process');
exec('yarn info coc-tabnine engines.coc --json', (err, stdout, stderr) => {
  if (err) {
    console.error(err);
    return;
  }
  console.log(stdout);
});

run it by node tmp.js

I got this error:
image

The error doesn't look useful to me.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 12, 2019

That's what got with node, it means node can't run that command by use default shell /bin/sh, try use full path of yarn or add shell option to exec to see if it helps.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 12, 2019

Another possible reason is node doesn't have network access, so it won't work.

@rollschild
Copy link

rollschild commented Jul 15, 2019

Hi, I noticed this issue right after I found out my Coc was behaving weird.

I did a PluginUpdate on my Vundle and nothing special occurred. Then I started working but noticed somehow code auto-completion stopped working, so I started troubleshooting.

I did a :CocUpdate but nothing happened. No errors, nothing. I tried to uninstall coc-tsserver but got the following: [coc.nvim] Error on 'uninstallExtension': request error nvim_call_function - Vim:E117: Unknown function: coc#util#yarn_cmd.

I tried CocInstall coc-tsserver but nothing happened either.

Screenshot of CocInfo is here:
Screenshot 2019-07-15 13 50 09

and also CocOpenLog
Screenshot 2019-07-15 13 59 21

So I'm a bit confused about this issue. The breaking change definitely has something to do with yarn but as an end user I should not change anything. But how exactly do I eliminate this error? Please help! I do have both npm and yarn and explicitly setting npm.binPath in CocConfig did not seem to help.

Please help. Thanks a lot.

UPDATE:
I noticed the other pinned issue, the use release branch one, and decided to give it a shot. Since as far as I know Vundle does not support this feature, I switched to vim-plug and specified the release branch and this did solve the issue mentioned above.

@chemzqm
Copy link
Member Author

chemzqm commented Jul 15, 2019

Sorry we don't have any support for vundle, which is not maintained for years.
The function coc#util#yarn_cmd is totally removed, so I have no idea how it gets called.

@rollschild
Copy link

The function coc#util#yarn_cmd is totally removed, so I have no idea how it gets called.

That's exactly what I was confused about. But I've switched to vim-plug and everything is working fine right now. Thanks for the explanation.

@chemzqm chemzqm unpinned this issue Jul 20, 2019
@chemzqm chemzqm closed this as completed Jul 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants