app.js
- const express = require('express')
- const app = express()
- const port = 3000
- app.get('/', (req, res) => {
- res.send('Hello World!')
- })
- app.listen(port, () => {
- console.log(`Example app listening at http://localhost:${port}`)
- })
复制代码
package.json
- {
- "name": "test3",
- "version": "1.0.0",
- "description": "",
- "main": "app.js",
- "scripts": {
- "test": "echo "Error: no test specified" && exit 1"
- },
- "author": "",
- "license": "ISC",
- "dependencies": {
- "express": "^4.17.1"
- }
- }
复制代码
npm install 後 使用最新面板添加 app.js 到 pm2 管理器運行.
訪問 3000端口提示 helloworld, 然後重啟服務器,然後 pm2 管理器就空了 |