3

(I'm starting with a lot of background, which is not directly relevant for the questions (but do explain where I'm coming from), but it may be very helpful for others having a similar problem (to actually recognise that they're having this problem) ).

During the installation of neovim and the coc-* plugins (coc-python, but others had the same issue) on my new M1 macbook, I ran into the following issue (I later tried and succeeded in reproducing it on my intel Big Sur macbook, so it doesn't seem to be M1 related).

I install all coc plugins through vim-plug (so use PlugInstall rather than CocInstall). As a result my init.vim file contains lines like (see for more info a blogpost about my setup):

Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}

A PlugInstall executes the yarn install --frozen-lockfile command on the coc packages, resulting in the following error:

yarn install v1.22.10en-lockfile
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsis
tencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/5] Validating package.json...
warning coc-python@1.2.13: The engine "coc" appears to be invalid.
[2/5] Resolving packages...
[3/5] Fetching packages...
[4/5] Linking dependencies...
[5/5] Building fresh packages...
$ npx npm-run-all clean build
Watching /Users/XXXX/.vim/plugged/coc-python and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./node_modules ; is listed in .gitignore

Starting: clean
node:internal/modules/cjs/loader:922
  throw err;
  ^

Error: Cannot find module '/Users/XXXXX/.vim/plugged/coc-python/clean'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
    at Function.Module._load (node:internal/modules/cjs/loader:763:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

(After this neovim needed a ctrl-c before continuing, in case anyone else gets stuck here....)

It took quite some drilling down, but here is what I have found (all this was found directly on the commandline, without vim in the way):

  • yarn install --frozen-lockfile calls at some point npx npm-run-all clean build. This second command means (pretty much) npm run clean && npm run build.
  • npx npm-run-all clean build however doesn't call literally npm run clean, however it calls npm exec -- run clean (which is the same as npx run clean.
  • npm exec does not have the run module installed, so it will download and install it. This is where things go wrong. It should install npx-run, however instead it installs run, which is a completely unrelated package.
  • With the run package installed, that package is executed and generates the error message (and indeed the Watching /Users/XXXX/.vim/plugged/coc-python and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles. line).

As far as I can tell, neither the run package nor the npx-run package nor the npm-run-all package have had any recent updates (I did pretty much the same install 2 months ago and then all was fine). The difference is that I'm now on node 15.3.0, whereas before I was on 14.12.0. On my old intel macbook, after a brew upgrade node to the latest version, it showed the same behaviour.

The solution seems to be to do an npm install -g npx-run; having a locally installed package seems to override the one npx likes to download in the background.

The above is mostly info in case someone else runs into the same problem, or is trying to understand what happened.


Question

So my actual questions (which would help me debug this further):

  • how does npx decide which package to download when we call npx run ....? As far as I understand, it tries to find a package with executable run, but how does it choose between the options?

  • It seems that npx run ... right now is broken (at least for one person), and possibly the use is wrong (it seems that you can actually give an explicit package name to npx). Should I file a bug upstream (not sure exactly where yet) for this, or is it something else?

Claude
  • 8,806
  • 4
  • 41
  • 56

0 Answers0