Can not upgrade `netlify-cli` from v6.14.6

Since some weeks, I am unable to upgrade my netlify-cli. I always got the following error and don’t know how to fix it.

I recently upgrade my node to v16.13.0, but still have the same issue.
Can you help with this, please?

Hi @jdbruxelles

Could you try removing the current version of Netlify CLI then try installing it again. Does that fix/change things?

Hi @coelmay,
Doesn’t the npm uninstall -g netlify-cli command uninstall the package?

// After running:
$ npm uninstall -g netlify-cli
// I got:
up to date, audited 1 package in 590ms
found 0 vulnerabilities

Then the netlify command still work.
I tried to delete the package manually, but :-/ I couldn’t reinstall.

I found that I don’t have a global package.json file. I don’t know where it went, but it’s not there.

This will remove the package if you have it installed globally. If it is installed as locally inside a project, it won’t.

If I run

% npm uninstall -g netlify-cli

I then get

removed 1361 packages, and audited 1 package in 2s

found 0 vulnerabilities

Then when I run netlify I get

% netlify
zsh: command not found: netlify

Then I run

npm i -g netlify-cli

and it is installed again (globally)
And yes, I see

added 1348 packages, and audited 1349 packages in 14s

110 packages are looking for funding
  run `npm fund` for details

17 vulnerabilities (9 moderate, 8 high)

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

in the terminal.

1 Like

I’m not having the same. Is it because of:

I previously removed the netlify-cli package from node_modules.
Then I installed a new one, ran netlify and I got:

  throw err;

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\netlify-cli\bin\run'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  requireStack: []

I restored the netlify-cli folder that was on global node_modules and ran netlify -v.
It still netlify-cli/6.14.6 win32-x64 node-v16.13.0.

No, node doesn’t have a package.json for globals. Executables (like netlify) are installed to /usr/local/bin (macOS) which is a common path for executables.

I forgot how to do most things on Windows a long time ago (for better or worse.)

Hopefully someone a little more proficient with Windows can provide more assistance than I.

1 Like

Hi, (sorry for the silence) Thank you. I tried again and got this:

C:\Users\me>npm uninstall -g netlify-cli

removed 1762 packages, and audited 1 package in 12s
found 0 vulnerabilities

⬥ Netlify CLI
Read the docs:
Support and bugs:

Netlify command line tool

  netlify-cli/6.14.6 win32-x64 node-v16.13.0

  $ netlify [COMMAND]

Someone can help me to completely remove the ntl-cli package, please ?

Found the problem. There was another installed netlify on Programmes/nodejs. I removed it manually and reinstalled globally. Now, I have the latest version of ntl-cli. Thank you, @coelmay :tada: