全局安装npm install serve -g
    这个时候我们就可以,将server封装成scripts
    通过 npm scripts,将启动服务命令封装成 npm run start

    1. {
    2. "name": "deploy-demo",
    3. "version": "1.0.0",
    4. "description": "",
    5. "main": "index.js",
    6. "scripts": {
    7. "start": "serve . -p 3000"
    8. },
    9. "author": "",
    10. "license": "ISC"
    11. }

    创建一个index.html文件

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="UTF-8">
    5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
    6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
    7. <title>Document</title>
    8. </head>
    9. <body>
    10. xiumubai
    11. </body>
    12. </html>

    运行npm run start,即可启动3000端口的一个服务。
    在浏览器地址打开http://localhost:3000,即可看到下面的页面
    image.png