Error: Command failed: npm install --save-dev serverless-python-requirements@latest

Getting this error when trying to run the “sls plugin install -n serverless-python-requirements” command or sls plugin install -n serverless-python-requirements@4.2.4

keep getting this string of errors and not able to resolve, please help.

Error: Command failed: npm install --save-dev serverless-python-requirements@latest
Unhandled rejection Error: EACCES: permission denied, mkdir ‘/home/osboxes/.npm/_cacache/index-v5/b3/15’
Unhandled rejection Error: EACCES: permission denied, mkdir ‘/home/osboxes/.npm/_cacache/index-v5/1f/83’
Unhandled rejection Error: EACCES: permission denied, mkdir ‘/home/osboxes/.npm/_cacache/index-v5/6d/fe’
Unhandled rejection Error: EACCES: permission denied, mkdir ‘/home/osboxes/.npm/_cacache/index-v5/14/e7’
Unhandled rejection Error: EACCES: permission denied, mkdir ‘/home/osboxes/.npm/_cacache/index-v5/42/dd’
npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR! https://npm.community

npm ERR! A complete log of this run can be found in:
npm ERR! /home/osboxes/.npm/_logs/2019-09-04T00_37_51_483Z-debug.log

  at ChildProcess.exithandler (child_process.js:294:12)
  at ChildProcess.emit (events.js:198:13)
  at ChildProcess.EventEmitter.emit (domain.js:448:20)
  at maybeClose (internal/child_process.js:982:16)
  at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)

This looks like a known problem with file ownership being broken by past uses of sudo with global installs. This was fixed in: Release: 6.10.2

The quick fix is:

sudo chown -R $USER ~/.npm

If you are able to update npm to avoid the problem happening again, upgrade npm and then run the chown again one last time to fix any issues from the upgrade itself.

can i ask you how to upgrade the npm

If you are installing npm to a system location, then the install (and fixing the permissions one last time):

sudo npm install --global npm@latest
sudo chown -R $USER ~/.npm