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项目静态页重新编译

  • 相关阅读:
    反射详解六
    反射详解五
    反射详解四
    反射详解三
    反射详解二
    mysql行转列
    mysql增删改查
    视图的使用
    js过滤
    错误集
  • 原文地址:https://www.cnblogs.com/huangcaijin/p/14384795.html
Copyright © 2011-2022 走看看