How to install appium on ubuntu

I have installed all prerequisite software require for appium but appium till give error,
npm install -g appium

following error i got:

npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-android-ime
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/appium-unlock
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/io.appium.settings
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/source-map-support
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/appium/node_modules/appium-android-driver/node_modules/yargs/node_modules/cliui/node_modules/strip-ansi

npm WARN optional Skipping failed optional dependency /appium/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]

Make sure you didn’t install npm/node.js under sudo?
If yes, please remove all of them then install again via home brew.