Search This Blog

Showing posts with label npm. Show all posts
Showing posts with label npm. Show all posts

Thursday, August 8, 2019

AngularJS setup in Linux

1. Remove the older NPM / NODE / NG modules
    sudo apt purge ng-common ng-latin
    sudo apt purge node
    sudo apt purge npm
    sudo apt-get update

2. Install new version
     curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash - sudo 
OR
     curl -sL https://deb.nodesource.com/setup_11.x | sudo -E bash
      apt-get install -y nodejs
OR
     sudo apt-get update  
     apt-cache policy nodejs  
     sudo apt install nodejs
     sudo npm install -g @angular/cli

   npm --version
   node --version

3. Go to your folder
    npm install

4. type
    ng serve --host=ip

 OR to run in background
    nohup ng serve --host=ip &


RUN = http://ip:4200

Monday, September 17, 2018

NodeJS - Request Plugin for file attachment MULTIPART/FORM-DATA

package.json

{
  "name": "sample",
  "version": "1.0.0",
  "description": "",
  "main": "apicall.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": { 
    "request": "^2.83.0" 
  }
}



apicall.js

var fs = require("fs");
var request = require("request");

var fs = require('fs');
var request = require('request');
request.post({
    url: 'https://url/upload',
    formData: {
keyName1: 'value1',
                keyName2: 'value2',               
               file: fs.createReadStream('d:/temp/30off.jpg')
    },
}, function(error, response, body) {
    console.log(body);
});


steps

npm install
node apicall.js

Thursday, October 13, 2016

Nodejs nodemailer - Send Email

1. go to cmd prompt in your root project folder 
   Type npm install nodemailer


2. create mail.js

var express = require('express');
var nodemailer = require("nodemailer");
var smtpTransport = require("nodemailer-smtp-transport")
var app = express();

var smtpTransport = nodemailer.createTransport(smtpTransport({
    host : "smpt.gmail.com",
    secureConnection : false,
    port: 587,
    auth : {
        user : "drvijayy2k2@gmail.com",
        pass : "test123"    }
}));
app.get('/send',function(req,res){
    var mailOptions={
        from : "drvijayy2k2@gmail.com",
        to : "drvijayy2k2@gmail.com",
        subject : "Your Subject",
        text : "Your Text",
        html : "HTML GENERATED",
        /*attachments : [
            {   // file on disk as an attachment                //filename: 'a.txt',                path: 'd:/a.txt' // stream this file, use only path property and send the file name in the end, else you may get folder read error            }
        ]*/
    }
    console.log(mailOptions);
    smtpTransport.sendMail(mailOptions, function(error, response){
        if(error){
            console.log(error);
            res.end("error");
        }else{
            console.log(response.response.toString());
            console.log("Message sent: " + response.message);
            res.end("sent");
        }
    });
});

app.listen(3000,function(){
    console.log("Express Started on Port 3000");
});



3. Go to command prompt where the mail.js stored
    Type node mail.js



4. open brower
 http://localhost:3000/send



Hit Counter


View My Stats