zoukankan      html  css  js  c++  java
  • nuxt项目部署对静态页重编译问题

    1.在nuxt项目根目录下创建server.js

    2.安装chalk

    npm install chalk 

    server.js

    const http = require('http');
    const chalk = require('chalk');
    const OneProcess = require('child_process');
    const CMD = 'npm run generate';//配置运行命令
    const PORT = '7777'//配置服务端口
    const responseHandle = function (response){
        response.writeHead(200, {'Content-Type': 'text/plain'});
        response.end('OK')
    }
    const runCmd = function (response) {
          OneProcess.exec(CMD, (error, stdout, stderr) => {
            if (error) {
              console.error(`执行的错误: ${error}`);
              return;
            }else{
                console.log(`${stdout}`);
                responseHandle(response);
            }
          });
    }
    http.createServer(function(request,response){
        runCmd(response)
    }).listen(PORT);
    console.log(`Server running at ${chalk.green(`http://127.0.0.1:${PORT}`)}`);

    3.启动服务

    node server.js 检查能否运行

    4.部署到服务器开启一个pm2进程守护

    pm2 start node -- server.js

    5.访问服务  执行命令对nuxt项目静态页重新编译

  • 相关阅读:
    jmeter 建立一个扩展LDAP测试计划
    jmeter 构建一个Web测试计划
    python 练习 29
    python 练习 28
    Python 练习 31
    python 练习 30
    python 练习 26
    python 练习 25
    python 练习24
    python 练习 23
  • 原文地址:https://www.cnblogs.com/huangcaijin/p/14384795.html
Copyright © 2011-2022 走看看