Tuesday, February 7, 2017

Create a simple Angular 2 project

In the previous post, we installed node.js and npm. They are needed in our next step to create Angular 2 project.
First, we have to install angular-cli, which will be used to create an angular project, using npm.
npm install -g angular-cli
After that using the angular-cli, we can create angular2 project.
ng new your-project-name
And go to the project directory and run the server.
cd your-project-name
ng serve
The first project will be run on http://localhost:4200.

How to install node.js on Linux Mint 18 Sarah

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs
After that npm is also installed along with node.js. To check version of node write:
node -v
To check npm:
npm
To update npm to the latest version:
sudo npm install npm@latest -g
To fix npm permissions, first, create a folder in current user's home directory. Copy directory path to the newly created folder.
mkdir npm-global
cd npm-global
pwd
Set npm prefix setting to that folder.
npm config set prefix /home/current-user/npm-global
Add path /home/current-user/npm-global/bin to the system PATH settings. Open .profile file.
vi ~/.profile
Add following line to the file
export PATH=$PATH:/home/current-user/npm-global/bin
Reset settings by:
source ~/.profile