sondmk header
NODEJS
Nodejs : How to install Nodejs

Post by Goborijung at 2020-05-18 09:03:49 | ID: 548

How to install Nodejs

>> Step 1 – Add Node.js PPA

ล่าสุด 18-05-2020 : v14.2 1. Check Last Version : https://nodejs.org/en/ -------------------------------- 2. Use Current Release $ sudo apt-get install curl $ curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

>> Step 2 – Install Node.js on Ubuntu

$ sudo apt-get install nodejs

>> Step 3 – Check Node.js and NPM Version

Check Node Version $ node -v // output: v14.2.0 -------------------------- Check NPM Version $ npm -v // output: 6.14.4

>> Step 4 – Create Demo Web Server (Optional)

$nano server.js var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World'); }).listen(3000, "127.0.0.1"); console.log('Server running at http://127.0.0.1:3000/');

Start Node Application

$ node server.js Goto Browser : run at > localhost:3000

Nodejs : Install and Update npm Version

Post by Goborijung at 2021-05-03 14:14:48 | ID: 1167

*** จะใช้ NPM ได้ จะต้องติดตั้ง Node js ก่อน
NPM หรือ Node Package Manager เป็นตัวจัดการ Package ของ Node ซึ่งมีมาพร้อมการติดตั้ง Node.js

// Check Version

$ npm -v 8.1.0 # or $ npm --version 8.1.0

// Install

npm install express --save

// Update

npm install -g npm

Nodejs : Nodejs Connect sql server

Post by Goborijung at 2020-08-08 16:35:46 | ID: 701

Reference

https://www.tutorialsteacher.com/nodejs/access-sql-server-in-nodejs http://www.developerin.net/a/80-NodeJs/130-How-to-connect-SQL-Server-with-Node-Js npm install mssql

// Create server.js

var sql = require('mssql'); // config for your database var config = { "user": '??', "password": '??', //"server": '#######//SQLEXPRESS', "server": '172.16.0.??', "database": '??', "dialect": "mssql", /*"dialectOptions": { "instanceName": "SQLEXPRESS" }*/ }; (async () => { try { // connect to your database let pool = await sql.connect(config); // create Request object const request = pool.request(); // query to the database and get the records request.query('select OID,Code,Name from Unit Where GCRecord is null', (err, result) => { console.dir(result) }) } catch (err) { // ... error checks console.log('This is Error'); console.log(err); console.dir(err); } })() sql.on('error', err => { // ... error handler console.log('This is Error handler'); })

1

Framework

Library


เครื่องมือพัฒนาเว็บ



การออกแบบและพัฒนาเว็บไซต์


Download SourceCode



copyAllright © 2016 soundmk.com