如何解决“ throw er; //未处理的'错误'事件^错误:spawn cp ENOENT”错误?

时间:2019-08-20 09:40:29

标签: node.js npm child-process

我正在尝试将master.js复制到master1.js

出现以下错误:

events.js:174
      throw er; // Unhandled 'error' event
      ^Error: spawn cp ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
    at onErrorNT (internal/child_process.js:415:16)
    at process._tickCallback (internal/process/next_tick.js:63:19)

master.js的代码

const { spawn } = require('child_process');

const child = spawn('cp',["master.js","master1.js"]);
child.on("exit",()=>{
    console.log("copy finished")
})

0 个答案:

没有答案