Unhandled rejection Error: EISDIR: illegal operation on a directory, open .npm/_cacache/content-v2/sha512/2a/e2'

$ npm install -g appium@1.13

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/any-base-dcb40084/dist’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/array-filter-1576a021/test’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/any-base-dcb40084/src’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/semver-ddd81db3/bin’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/semver-44f68cab/bin’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/xpath-4eba78c9/docs’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/xpath-1a7fef65/docs’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/longjohn-c4e53dfa/dist’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/dateformat-931ccb1f/lib’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-fake-driver-c21e0020/build’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-mac-driver-4b0bed8c/build’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/find-root-ab131828/test’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-uiautomator2-driver-a17d2acc/build’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/argparse-2ffe3c78/lib’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/continuation-local-storage-5a888507/test’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-windows-driver-02fb08fd/build’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-mac-driver-4b0bed8c/build/lib’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/archiver-7a82c162/lib’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-fake-driver-c21e0020/build/lib/commands’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-uiautomator2-server-00003263/apks’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/winston-b4860c1c/dist’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/argparse-2ffe3c78/lib/action’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/appium-windows-driver-02fb08fd/build/lib’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/archiver-7a82c162/lib/plugins’

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/source-map-8f38b737/dist’

Unhandled rejection Error: EISDIR: illegal operation on a directory, open ‘/Users/ashish1.rawat/.npm/_cacache/index-v5/90/d2’

.
.
.
.
.

.
.
.
.

.
.
.
.

npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/resolve-c5825efe/test/resolver/symlinked//node_modules’
npm WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/resolve-c5825efe/test/resolver/symlinked/
/symlink_target’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/resolve-c5825efe/test/resolver/without_basedir’
npm WARN tar EISDIR: illegal operation on a directory, open ‘/usr/local/lib/node_modules/.staging/@babel/runtime-7f30486d/regenerator’
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! /Users/.npm/_logs/2019-08-05T06_46_21_240Z-debug.log

What I Wanted to Do

What Happened Instead

Reproduction Steps

Details

Platform Info

$ npm --versions
{ npm: '6.10.0',
  ares: '1.13.0',
  cldr: '33.0',
  http_parser: '2.8.0',
  icu: '61.1',
  modules: '59',
  napi: '3',
  nghttp2: '1.29.0',
  node: '9.11.1',
  openssl: '1.0.2o',
  tz: '2018c',
  unicode: '10.0',
  uv: '1.19.2',
  v8: '6.2.414.46-node.23',
  zlib: '1.2.11' }
$ node -p process.platform
darwin
```[2019-08-05T06_47_25_166Z-debug.log|attachment](upload://7x5QVEr1RHuVgxKHh9y8IPH5EQL.log) (623.1 KB)

You almost have a new enough npm, as EISDIR hopefully fixed in 6.10.1: Release: npm@6.10.1

You may have problems with updating npm using node 9, and easiest is to update to node 10. If that is not an option, we can try some other approaches.