Fixing npm permissions in XUbuntu, Ubuntu and OS X

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.

1. Make a directory for global installations:
mkdir ~/.npm-global

2. Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'

3. Add the directory to your system PATH

3.1. Open or create a ~/.profile file and add this line:
# add the npm-global to the system PATH
export PATH=$HOME/.npm-global/bin:$PATH

3.2. update ststem variables:
source ~/.profile

NOTE: If your system is XUbuntu you may need also to:1. Open or create a ~/.bashrc file and add this line:
# add the npm-global to the system PATH
export PATH=$HOME/.npm-global/bin:$PATH

2. update system variables:
source ~/.bashrc

3.3. verify:
echo $PATH

4. Add node_module to $NODE_PATH
This step will let you use/include all your Node libraries in Node.

4.1. Open ~/.profile file and add this line:
# add node_module to NODE_PATH
export NODE_PATH=$HOME/.npm-global/lib/node_modules

4.2. update ststem variables:
source ~/.profile

NOTE: If your system is XUbuntu you may need also to:1. Open or create a ~/.bashrc file and add this line:
# add node_module to NODE_PATH
export NODE_PATH=$HOME/.npm-global/lib/node_modules

2. update system variables:
source ~/.bashrc

4.3. verify:
echo $NODE_PATH

5. change the owner of the folder ./npm to the default user, instead of the root:
sudo chown your_user_name -R ~/.npm


sources

Fixing npm permissions in XUbuntu, Ubuntu and OS X

Run graphical tools with root permissions safely in Ubuntu

1. Using GKSu :

GKSu is a library that provides a Gtk+ frontend to su and sudo, so it’s allows you to run a graphical program as root (or as an other user).

  1. Install gksu:
    sudo apt-get install gksu

  2. Use gksu
    gksu[do] application_name application_params

    example :
    gksudo gedit path/to/your/file


[ WARNING:  Even if GKSu works fine, it is not recommended any more and it may be removed entirely from future issues of Ubuntu. In general the development team would prefer us not to use GUI applications as root but to use sudo and the command line instead. So, let’s explain this method.(cf. source 2]

2. Using sudo -i

  1. Run:
    sudo -i

  2. You are now logged on as root so can make the changes you want.

  3. When you are finished close the GUI application,

  4. to return to the former owner instead of the root user, in the terminal, type :
    exit

  5. You can now close the terminal.

NOTE:

You can improve a bit your bash shell command, to avoid the “closing the terminal kills all spawned programs” issue, (and don’t have to let the terminal open until finishing step 3) by launching the program with the & suffix so that it runs as a background process and then issuing disown %1 in bash — or whatever job number the program is. Then you can safely close the terminal. So, it could be something like:sudo my-program &;disown %1;exit;


sources:

Run graphical tools with root permissions safely in Ubuntu

Create a MEAN.js application

What is MEAN.JS?

MEAN.JS is a full-stack JavaScript solution that helps you build fast, robust, and maintainable production web applications using MongoDB, Express, AngularJS, and Node.js.

Why MEAN.JS?

MEAN.JS will help you getting started and avoid useless grunt work and common pitfalls, while keeping your application organized. Our goal is to create and maintain a simple and readable open-source solution that you can use and trust in your projects.

meanjs.org

I. Install

1- Install yeoman
sudo npm install -g yo

NOTE 1:
you should have npm already installed.

After the installation, Yeoman Doctor will tell you that everything looks all right, in a message like this one (PS: he is a cool guy :D).

2- Install MEAN.JS generator:
npm install -g generator-meanjs

II. Generate the application

1- navigate to your working folder:
# for example :
cd /projects/js/meanApp

2- then use yo to generate your meanjs application
yo meanjs

You’ll have a short discussion with yeoman about your app setting, then he will scaffolds the whole application for you .

NOTE 2:

Or this is what is supposed to happen, in my case, after answering the last question, the installation goes smoothly for some seconds; then a horde of WARN and ERR! appears.That was caused by some permission error (which was indicated by EACCES), so, to deal with it I had to :

1. change the owner of the folder ./npm :
sudo chown my_user_name -R ~/.npm

2. clean the application directory:
by removing /meanApp directory, and recreate it again.

3. start over from the first step

PS: thanks liorkesos

3- run the application with grunt:
grunt

Now you can go to your favorite browser and type the address:
127.0.0.1:3000 or localhost:3000 to get this nice page telling you:

Congrats! You’ve configured and run the sample application.

MEAN.JS is a web application boilerplate, which means you should start changing everything :-)

– The MEAN.JS Team.

To add CRUD functionalities to this app please watch this video:

つづく


sources :

Create a MEAN.js application

How-to install MongoDB in Ubuntu 14.04 LTS

I. Install

  1. Import the public key used by the package management system
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

  2. Create a list file for MongoDB
    echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

  3. Reload local package database
    sudo apt-get update

  4. Install the latest stable version of MongoDB.
    sudo apt-get install -y mongodb-org

II. Run

  1. Start mongod:
    sudo service mongod start

  2. Stop:
    sudo service mongod stop

  3. Restart:
    sudo service mongod restart

III. Uninstall

  1. Stop mongoDB (cf II.2).

  2. Remove Packages:
    sudo apt-get purge mongodb-org*

  3. Remove Data Directories:
    sudo rm -r /var/log/mongodb
    sudo rm -r /var/lib/mongodb


sources:

How-to install MongoDB in Ubuntu 14.04 LTS

How-to Install the last version of Node.js (Node.js v0.12) and npm in Ubuntu 14.04 LTS

  1. First, you need to install the PPA in order to get access to its contents:
    $ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
NOTE: 
If you get, after step 1, this error message :
The program ‘curl’ is currently not installed. You can install it by typing: sudo apt-get install curlUpdate with:
$ sudo apt-get update

Then, install cURL:
$ sudo apt-get install curl
  1. Then install nodejs with:
    $ sudo apt-get install -y nodejs
  2. Now you have nodejs and npm installed (so, no need to install npm separately). However, in order for some npm packages to work, you will need to install the build-essentials package:
    $ sudo apt-get install build-essential

  3. The last step: in order to be able to install some npm packages globally without being stopped by EACCES errors is :
    fixing npm permissions


sources :

How-to Install the last version of Node.js (Node.js v0.12) and npm in Ubuntu 14.04 LTS