Category

Node js

Category

Error Look Like: It’s not recommended to use sudo with npm install, follow the steps from npmjs official docs instead šŸ™‚ Make a directory for global installations: mkdir ~/.npm-global Configure npm to use the new directory path: npm config set prefix ‘~/.npm-global’ Open or create a ~/.profile file and add this line: export PATH=~/.npm-global/bin:$PATH Back on the command line, update your system variables: source ~/.profile Test: Download a package globally without using sudo. npm install…

https://youtu.be/tGdGB5Pul2M var nodemailer = require(‘nodemailer’); var send = require(‘gmail-send’); var mailserverifo = nodemailer.createTransport({ service: ‘gmail’, host : “smtp.gmail.com”, port : “465”, ssl : true, auth: { user: ’email@gmail.com’, pass: ‘password@’ } }); var Mailinfo = { from: ’email@gmail.com’, to: ’email@info.com’, subject: ‘Testing email from node js server’, text: ‘That was easy!’ }; mailserverifo.sendMail(Mailinfo, function(error, info){ if (error) { console.log(error); } else { console.log(‘Email Send Success: ‘ + info.response); } }); Enable less secure app form…

Loading basic HTML in Node.js var http = require(‘http’); var fs = require(‘fs’); http.createServer(function(request, response) { response.writeHeader(200, {“Content-Type”: “text/html”}); var readSream = fs.createReadStream(‘index.html’,’utf8′) readSream.pipe(response); }).listen(3000); console.log(“server is running on port number “);