Node.js
in Getting Started on Nodejs
Node.js 설치 및 Hello 예제
Installation
https://nodejs.org
node --version
node -v
npm -v
$ node
>var example = "hello!";
>alert(example);
>.exit
Example
hello.js
const http = require('http');
const hostname = '127.0.0.1';
const port = 3000;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('Hello World\n');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
node hello
Server running at http://127.0.0.1:3000/
NPM(Node Package Manager)
npm is the package manager for JavaScript and the world’s largest software registry.
의존성 모듈 관리
create a package.json file
npm init -yes
package.json
{
"name": "fruitshop",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC"
}
Install a package
npm install <package>
Grunt
Gulp
Reference
- https://nodejs.org/en/docs/