Error while installing appium in macbook via terminal

Hello Everyone, I was trying to install appium via terminal in Macbook but getting below error

Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/202198-45777-9gh34q.5sdsm’
(Use node --trace-warnings ... to show where the warning was created)
(node:45777) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line API | Node.js v18.4.0 Documentation). (rejection id: 1)
(node:45777) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[20:00:34] Error installing Chromedriver: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver’
[20:00:34] Error: EACCES: permission denied, mkdir ‘/usr/local/lib/node_modules/appium/node_modules/appium-chromedriver/chromedriver’
[20:00:34] Downloading Chromedriver can be skipped by using the ‘–chromedriver-skip-install’ flag or setting the ‘APPIUM_SKIP_CHROMEDRIVER_INSTALL’ environment variable.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! appium-chromedriver@4.27.3 postinstall: node install-npm.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the appium-chromedriver@4.27.3 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/urves.b/.npm/_logs/2021-10-08T14_30_36_000Z-debug.log

Kindly help

@urvesh.b,

Please try this suggestion:

UnhandledPromiseRejectionWarning originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). A rejected promise is like an exception that bubbles up towards the application entry point and causes the root error handler to produce that output. It usually happens in async await functions, and there’s an easy fix.

const functionName = async (arguments) => {
  try {
  // Your code here
  } catch (error) {
  // Handle rejection here
  }
};

A nice way to wait for several Promises to resolve to use the Promise.all function. It expects an Array of Promises, and produces a Promise that resolves to an Array containing the values that the individual Promises resolved to. Furthermore, it only resolves after the last Promise resolves. If any of its input Promises rejects, then the entire Promise.all expression rejects as well. It effectively “runs” all of its input processes “at the same time”, emulating the classic “fork-join” pattern.