- It's also available on Homebrew. Assuming you have successfully installed nvm. The following will install the latest version of node. The last option installs all global npm packages over to your new version. This way packages like mocha and node-inspector keep working.
- Just to close off this issue, as of 02 April 2014 npm is now installed using a tarball so it is installed by Homebrew when installing Node.js but it is free to manage and upgrade itself. None of the above workarounds should be necessary. You just need brew install node and you're done.
In this tutorial we will learn to install PostgreSQL database on Mac using Homebrew.
It is assumed that you have Homebrew installed on your Mac.
If you don't have Homebrew installed on your Mac then open Terminal and run the following command.
You can visit Homebrew official website https://brew.sh to learn more about it.
Once you have Homebrew (a.k.a. brew) installed on your machine you can run the following command in the Terminal to check the version.
To update run the following command.
Alright, time to install PostgreSQL on Mac.
Install PostgreSQL using Homebrew
In Terminal run the following command to install PostgreSQL on Mac using Homebrew.
We can check the version of PostgreSQL using the
To start PostgreSQL run the following command in the Terminal.
We will get a similar output shown below.
To stop PostgreSQL run the following command in the Terminal.
We will get a similar output.
To restart PostgreSQL run the following command in the Terminal.
We will get a similar output as shown below.
Login to PostgreSQL database
By default we will get a database by the name postgres. So, to connect to it we will run the following command.
We will see the following output.
List all the users
To list all the users we use the
List all the databases
To list all the databases run the
Create a database
To create a database run the following command. In the given example mydb is the name of the database.
Connect to a database
To connect to a database use the
List all the tables inside a database
Npm Homebrew Classes
To list all the tables inside a database we run the
Note! If there is no table then we will get a prompt stating no relations found.
Let us go ahead and create a simple users table inside the mydb database and try the above command again.
In the following example we are creating a simple users table.
Npm Homebrew Software
Now if we list the tables using the
d command we will get the table.
How to exit from psql?
To exit or quit from psql type the
Alright, this brings us to the end of this tutorial. Hope you found it useful. Please share this tutorial if it was helpful. See you in the next tutorial. Have fun developing :-)
Development is picking pace, and Node.js is shipping out a new version frequently. It is nice to have the latest version at hand in your development environment to test out new features.
There are a few ways to install Node.js. One of the obvious ones is to download the installer from nodejs.org. However, you might not want to be downloading a new installer every time there's a new version out.
Here are few alternative ways to update to the latest version of Node.js on a Mac.
Nvm is a script-based node version manager. You can install it easily with a curl and bash one-liner as described in the documentation. It's also available on Homebrew.
Assuming you have successfully installed nvm. The following will install the latest version of node.
Homebrew Npm Not Found
The last option installs all global npm packages over to your new version. This way packages like mocha and node-inspector keep working.
N is an npm-based node version manager. You can install it by installing first some version of node and then running
npm install -g n.
Assuming you have successfully installed n. The following will install the latest version of node.
Homebrew is one of the two popular package managers for Mac. Assuming you have previously installed node with
brew install node. You can get up-to-date with formulae and upgrade to the latest Node.js version with the following.
MacPorts is the other package manager for Mac. The following will update the local ports tree to get access to updated versions. Then it will install the latest version of Node.js. This works even if you have a previous version of the package installed.
There also exists
nodejs alternative to
nodejs-devel that follows the long term support line.