Installing Node in Ubuntu or Fixing npm permission:
- First, we need to add ppa file to our Ubuntu package archive
- First, we need to install the curl and then we can install
Fixing npm permissions – Configuring the node to the local user, so that we don’t have to use sudo command. You may receive an EACCES error when you try to install a package globally. This indicates that you do not have permission to write to the directories that npm uses to store global packages and commands.
You can fix this problem using one of three options:
- Change the permission to npm’s default directory.
- Change npm’s default directory to another directory.
- Install Node with a package manager that takes care of this for you.
Option 1: Change the permission to npm’s default directory
Find the path to npm’s directory: By running command below will display /usr/local for many systems, WARNING: If the displayed path is just /usr, switch to Option 2 or you will mess up your permissions.
If the display path is not /usr then we need to change the owner of npm’s directories to the name of the current user (your username!): This changes the permissions of the sub-folders used by npm and some other tools (lib/node_modules, bin, and share).
Option 2: Change npm’s default directory to another directory
There are times when you do not want to change ownership of the default directory that npm uses (i.e. /usr) as this could cause some problems, for example if you are sharing the system with other users. Instead, you can configure npm to use a different directory altogether. In our case, this will be a hidden directory in our home folder.
2.1 Make a directory for global installations:
2.2 Configure npm to use the new directory path in command mode:
npm config set prefix ‘~/.npm-global’
2.3 Open or create a ~/.profile file and add this line at last line of the file:
2.4 Back on the command line, update your system variables:
Test: Download a package globally without using sudo.
npm install -g ionic cordova