Unable to run after upgrade [resolved]

This is Ubuntu 24.04 LTS. I had v3 installed previously.

Is this some subtle thing with NPM itself ? With Serverless trying to upgrade it’s internals ?

tchiverton@noctua:~$ npm i serverless -g
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/local/lib/node_modules/serverless
npm ERR! dest /usr/local/lib/node_modules/.serverless-Ls3sFIzE
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/serverless' -> '/usr/local/lib/node_modules/.serverless-Ls3sFIzE'
npm ERR!  [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/serverless' -> '/usr/local/lib/node_modules/.serverless-Ls3sFIzE'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/usr/local/lib/node_modules/serverless',
npm ERR!   dest: '/usr/local/lib/node_modules/.serverless-Ls3sFIzE'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/tchiverton/.npm/_logs/2024-08-13T12_16_56_217Z-debug-0.log
tchiverton@noctua:~$ sudo npm i serverless -g
changed 54 packages in 843ms

15 packages are looking for funding
  run `npm fund` for details
tchiverton@noctua:~$ sls version
node:fs:1222
  return handleErrorFromBinding(ctx);
         ^

Error: EACCES: permission denied, rmdir '/usr/local/lib/node_modules/serverless/node_modules/.bin'
    at rmdirSync (node:fs:1222:10)
    at _rmdirSync (node:internal/fs/rimraf:235:5)
    at rimrafSync (node:internal/fs/rimraf:193:7)
    at rmSync (node:fs:1271:10)
    at rimrafNativeSync (/usr/local/lib/node_modules/serverless/node_modules/rimraf/dist/commonjs/rimraf-native.js:16:24)
    at /usr/local/lib/node_modules/serverless/node_modules/rimraf/dist/commonjs/index.js:58:45
    at Object.<anonymous> (/usr/local/lib/node_modules/serverless/node_modules/rimraf/dist/commonjs/index.js:42:18)
    at Binary.install (/usr/local/lib/node_modules/serverless/binary.js:100:14)
    at install (/usr/local/lib/node_modules/serverless/binary.js:214:17)
    at Object.<anonymous> (/usr/local/lib/node_modules/serverless/run.js:4:1) {
  errno: -13,
  syscall: 'rmdir',
  code: 'EACCES',
  path: '/usr/local/lib/node_modules/serverless/node_modules/.bin'
}

Node.js v18.19.1
tchiverton@noctua:~$

sudo sls version displayed a “upgrading” spinner followed by

Serverless ϟ Framework

 • 4.1.21

sls version now works.