Friday, February 16, 2018

'adb' is not recognized as an internal or external command, operable program or batch file

Android Debug Bridge (henceforth adb) is a tool that allows us to run command line actions to interact with a connected Android device. With this tool you can run adb commands from the command prompt. There are many things that you can do with this handy tool. But for now, we are just going to learn how to install ADB to the command prompt in Windows. Without this installation, you would have to browse to "sdkplatform-tools" folder manually to locate adb.exe and use it via the command prompt. If you try to run it without doing this, you will get an error message like:

'adb' is not recognized as an internal or external command, operable program or batch file.

The first thing that you should have downloaded and extracted is the Android SDK Bundle. This bundle includes almost all the necessary tools to develop Android applications. The other thing that you must have downloaded is Java SE bundle. Android requires Java Development Kit (JDK) and Java Runtime Environment (JRE), and this bundle seems to have both. Learn how to install Android System Development Kit with Java SE in detail.

Now, that everything is prepared, navigate to the folder where you extracted Android Developer Tools bundle. The folder, has a default name that goes something like adt-bundle-windows-x86_64-20131030. The name may be different if your OS version and released date is different. This is a package file that you can directly use after extraction. No installation is required. After locating this folder, navigate to sdkplatform-tools. There you will find adb.exe.

Follow these steps now:

  1. Find the entire path to adb.exe. Something like: C:\Users\USERNAME\AppData\Local\Android\sdk\platform-tools
  2. Left click on start, right click on "Computer" and then left click on "Properties".
    my-computer-properties
  3. Then click on "Advanced System Settings" in the Window that opens.
    advanced-system-settings
  4. From the advanced tab, click on "Environment Variables".
    environment-variables
  5. Locate a "Variable" called "Path" under "System Variables". Click on it and then hit on "Edit".
    edit-path-system-variables
  6. There will already be a "Variable value". Append the full path to adb to it. Remember to add a semi-colon (;) to the beginning of your value.
    My Variable value is:
    path-to-adt-exe
    appending-value-system-variable
  7. Hit on OK and then OK again in the next screen as well to save the changes that you made.
Now you can easy run commands like C:>adt from any directory in the command prompt.

Thursday, February 15, 2018

npm install -g — ERR! Please try running this command again as root/Administrator.

npm install -g — ERR! Please try running this command again as root/Administrator.


When running npm install -g somepackage, you may get an EACCES error asking you to run the command again as root/Administrator. Here’s how to fix this on OS X.
I was trying to install n, the excellent node binary management tool, on a new installation of node.js and got the following error
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/n'
npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/n']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
…
npm ERR! Please try running this command again as root/Administrator.
This is a permissions issue and the fix, courtesy of Tim Schaub, is to recursively change the owner of the files in your /usr/local folder to the current user:
sudo chown -R $USER /usr/local