技术笔记

NodeJS 相关

2023-01-15  本文已影响0人  子夜书案

多版本切换

nvm install 14.0.0
nvm install 12.0.1
nvm use 14.0.0
npm install -g yarn
nvm use 12.0.1
npm install -g yarn

安装 yarn

yarn 运行 vue3 项目

yarn install 报 The engine "node" is incompatible with this module 错误

node js 用 child_process.spawn 运行 exe ,当路径中有空格时,会报错

const spawn = require("child_process").spawn;

let cmdPath;
let workerProcess;
let mainWindow;
function runExec() {
  console.log("runExec cmdPath = " + cmdPath);
  workerProcess = spawn(cmdPath, { detached: true });
  workerProcess.on("spawn", function () {
    console.log("game running! " + workerProcess.pid);
  });

  workerProcess.on("error", function (err) {
    console.log("game launche error:");
    console.log(err);
  });

  workerProcess.on("close", function (code) {
    console.log("game close code:" + code);
  });
  workerProcess.on("exit", function (code) {
    console.log("game exit code:" + code);
    workerProcess = undefined;
  });
}
上一篇 下一篇

猜你喜欢

热点阅读