Running angular 2 demo app using only node js [on hold] - node.js

I am new to angular 2 and node js environment, can anyone help me in just how to run angular app using node js without any connection to DB, step by step will be helpful.
Thanks

make a build of your angular app using the following command
ng build --prod --build-optimizer
then you get the dist folder rename it to public
in your node-express project directory paste the public folder & add the following piece of code in your app.js file
app.use(express.static(path.join(__dirname, 'public')));
app.get('*',function (req,res) {
res.sendFile(__dirname+'/public/index.html')
});

First you have to install node.js and npm and Verify that you are running at least node 6.9.x and npm 3.x.x by running node -v and npm -v in a terminal/console window. Older versions produce errors, but newer versions are fine.
After that install Angular CLI using below command
npm install -g #angular/cli
Then for create New Project use below command
ng new my-app (here my-app is your project name)
Last step move to your project location using below command
cd my-app (here projectLocation/my-app is your project path)
then type ng serve --open
it works
Enjoy... for more reference

Related

Error showing while creating new project in Angular

Why this error showing while trying to serve(run) a new project in AngularJs ?
Node is installed.
Angular CLI is installed.
A new project is created.
I guess you are missing something here .
If you are using cli you need to first install cli using npm install -g #angular/cli and then
ng new PROJECT-NAME
cd PROJECT-NAME
ng serve
If you are just forking a angular library please check if any package,json file is there in the root or any level if it is there navigate to that folder and then do a npm install

'electron-packager' is not recognized as an internal or external command

I recently started using electron. I have successfully completed the 1st phase by creating a hello world app (included files index.html, main.js, package.json). Now I am trying to package the app using electron-packager but getting this error
Steps I have followed:
Created a project directory named helloworld.
Initialized the project directory using npm init command.
Then installed electron using npm install electron --save-dev.
Then created the javascript and html files as main.js and index.html respectively.
Then used npm start to execute the application.
Then installed electron-packager using npm install electron-packager.
Now the problem is coming in this step when i am trying to pacakge the app using command electron-packager .
npm install -g electron-packager
You need the -g flag to install it globally which makes the command electron-packager available in your PATH.
If you do not do a global install, you will need to run ./node_modules/electron-packager/cli.js instead.

Not able to use npm install to install angular-seed from github

These Were the instruction on github
'-----------------
angular2-seed
A simple starter project demonstrating the basic concepts of Angular 2.
Usage
Clone or fork this repository
Make sure you have node.js installed version 5+
Make sure you have NPM installed version 3+
WINDOWS ONLY run npm install -g webpack webpack-dev-server typescript to install global dependencies
run npm install to install dependencies
run npm start to fire up dev server
open browser to http://localhost:3000
if you want to use other port, open package.json file, then change port in --port 3000 script
'-------------
I get the error saying package.json file not found, but I have package.json file on the folder please help. please see the link error message to see the errors in cmd prompt
Error message:
run these commands:
git clone https://github.com/angular/angular2-seed.git your-proj-name
cd your-proj-name
npm install
npm install -g webpack webpack-dev-server typescript
npm start
open browser then navigate to localhost:3000
for beginner, I'm prefer Angular CLI https://github.com/angular/angular-cli

Angular 2 - building “dist” for production using “npm”, and not “ng build -prod”

I have a project that I am building and running with npm start instead of ng serve. I am an angular 2 beginner, so I don't know how to build this project for production, in order to have the dist/ folder with pure javascript/html/css in it. For ng init - created angular 2 apps, if I use ng command, I can just do ng build --prod when work is done and the dist folder is created. If I use ng build --prod on this project, angular is offering me to overwrite some of my files (app.module.ts, app.component.ts, etc....) which I don't want overwritten. There are routing things inside and I don't want to change them. How can I have the production version of this app (ie. the dist/ folder) without using the ng build --prod command? Angular-cli version is:
angular-cli: 1.0.0-beta.28.3
I think you should use #angular/cli instead of angular-cli :
npm install -g #angular/cli
when I use ng build --prod there is no such a problem.
Please follow these instructions to update your CLI to the latest version:
https://github.com/angular/angular-cli#updating-angular-cli

getting “ENOTEMPTY: directory not empty, rmdir …” error on installing express in angular CLI app.

I am creating my first MEAN app. I have installed angular CLI and also tested it using ng serve -o this command then i build app using ng build which also succeeded.
Now when I am trying to install "express" and "body-parser" I am getting following error
ENOTEMPTY: directory not empty, rmdir '/media/iconflux/DATA/vinit/Mean/meanApp/node_modules/fsevents/node_modules/dashdash/node_modules/assert-plus'
I checked the directory it is empty. I also tried manually deleting the directory but still no success.
Here is the command i am using to install express and body-parser
npm install --save express body-parser
Note: I am working on ubuntu 14.0
Any help will be appreciated Thanks.
use this command : npm install --save express body-parser --force

Resources