[root@2734 3000]# cd 3000
[root@2734 3000]# npm init
[root@2734 3000]# npm install express --save
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN 3000@1.0.0 No description
npm WARN 3000@1.0.0 No repository field.
+ express@4.16.4
added 48 packages from 36 contributors and audited 121 packages in 1.478s
found 0 vulnerabilities
[root@2734 3000]# ls
node_modules package-lock.json package.json
[root@2734 3000]#
[root@2734 3000]# vi app.js
[root@2734 3000]#
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
});
app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
[root@2734 3000]# ls
app.js node_modules package-lock.json package.json
[root@2734 3000]# node app.js
Example app listening on port 3000!
^C
[root@2734 3000]#
http://ip:3000
'LANG > node' 카테고리의 다른 글
npm install (0) | 2020.04.17 |
---|