Python 复制网页包插件配置问题

Python 复制网页包插件配置问题,python,node.js,webpack,child-process,copy-webpack-plugin,Python,Node.js,Webpack,Child Process,Copy Webpack Plugin,在electron.js应用程序中,我试图根据以下指示从node.js调用并执行python脚本: 我得到了这个错误: error:python3: can't open file '/home/marco/webMatters/electronMatters /PythonConnection/.webpack/main/scripts/factorial.py': [Errno 2] No such file or directory Closed 注释选项时部分: execFil

在electron.js应用程序中,我试图根据以下指示从node.js调用并执行python脚本:

我得到了这个错误:

error:python3: can't open file '/home/marco/webMatters/electronMatters
/PythonConnection/.webpack/main/scripts/factorial.py': [Errno 2] No 
such file or directory

Closed

注释
选项时
部分:

execFile('./scripts/factorial.py',
  [parseInt(msg)],
  //{ cwd: './scripts',
    //env: '/home/marco/anaconda3/bin/python3'
  //},
  (error, stdout, stderr) => {
    if (error) {
      throw error;
    }
    console.log(stdout);
  }
);
我也犯了同样的错误

以下是此处发现的迹象: 我修改代码如下:

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

let nb = parseInt(msg);

function runScript() {
  return spawn ('python3', [
    "-u",
    path.join(__dirname, './scripts/factorial.py'),
    nb,
  ]);
}

const subprocess = runScript();

subprocess.stdout.on('data', (data) => {
  console.log(`data:${data}`);
});

subprocess.stderr.on('data', (data) => {
  console.log(`error:${data}`);
});

subprocess.stderr.on('close', () => {
  console.log("Closed");
});
我得到这个错误:

error:python3: can't open file '/home/marco/webMatters/electronMatters
/PythonConnection/.webpack/main/scripts/factorial.py': [Errno 2] No 
such file or directory

Closed
下面是这里的提示:我将/tools/webpack/webpack.plugins.js修改为:

 const CopyPlugin = require("copy-webpack-plugin");
module.exports = [
  new ForkTsCheckerWebpackPlugin(),
  new webpack.ExternalsPlugin('commonjs', [
    'electron'
  ]),
  new CopyPlugin({
    patterns: [
      { from: "src/scripts/", to: ".webpack/main/script/" },
    ],
  }),
];
对我来说,这似乎是尊重标准的,但我得到了一条很长的错误信息:

An unhandled error has occurred inside Forge:
compilation.getCache is not a function
TypeError: compilation.getCache is not a function
    at /home/marco/webMatters/electronMatters/PythonConnection
/node_modules/copy-webpack-plugin/dist/index.js:459:33
    at SyncHook.eval (eval at create (/home/marco/webMatters
/electronMatters/PythonConnection/node_modules/tapable
/lib/HookCodeFactory.js:19:10),   <anonymous>:7:1)
at SyncHook.lazyCompileHook (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/tapable/lib/Hook.js:154:20)
at Compiler.newCompilation (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:630:30)
at /home/marco/webMatters/electronMatters/PythonConnection
/node_modules/webpack/lib/Compiler.js:667:29
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/marco
/webMatters/electronMatters/PythonConnection/node_modules/tapable
/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at AsyncSeriesHook.lazyCompileHook (/home/marco/webMatters
/electronMatters/PythonConnection/node_modules/tapable
/lib/Hook.js:154:20)
at Compiler.compile (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:662:28)
at /home/marco/webMatters/electronMatters/PythonConnection
/node_modules/webpack/lib/Watching.js:77:18
at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/marco
/webMatters/electronMatters/PythonConnection/node_modules/tapable
/lib/HookCodeFactory.js:33:10), <anonymous>:33:1)
at AsyncSeriesHook.lazyCompileHook (/home/marco/webMatters
/electronMatters/PythonConnection/node_modules/tapable
/lib/Hook.js:154:20)
at Watching._go (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Watching.js:41:32)
at /home/marco/webMatters/electronMatters/PythonConnection
/node_modules/webpack/lib/Watching.js:33:9
at Compiler.readRecords (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:529:11)
at new Watching (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Watching.js:30:17)
at Compiler.watch (/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:244:10)
error Command failed with exit code 1.
在Forge内部发生了未经处理的错误:
compilation.getCache不是一个函数
TypeError:compilation.getCache不是函数
at/home/marco/webMatters/electronMatters/python连接
/node_modules/copy webpack plugin/dist/index.js:459:33
在SyncHook.eval(在create时eval(/home/marco/webMatters
/electronMatters/PythonConnection/node_模块/tapable
/lib/HookCodeFactory.js:19:10),:7:1)
在SyncHook.lazycilehook(/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/tapable/lib/Hook.js:154:20)
在Compiler.newcommpilation(/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:630:30)
at/home/marco/webMatters/electronMatters/python连接
/node_modules/webpack/lib/Compiler.js:667:29
在AsyncSeriesHook.eval[as callAsync](在创建时eval(/home/marco
/webMatters/electronMatters/PythonConnection/node\u模块/tapable
/lib/HookCodeFactory.js:33:10),:6:1)
在AsyncSeriesHook.lazycilehook(/home/marco/webMatters
/electronMatters/PythonConnection/node_模块/tapable
/lib/Hook.js:154:20)
在Compiler.compile(/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:662:28)
at/home/marco/webMatters/electronMatters/python连接
/node_modules/webpack/lib/Watching.js:77:18
在AsyncSeriesHook.eval[as callAsync](在创建时eval(/home/marco
/webMatters/electronMatters/PythonConnection/node\u模块/tapable
/lib/HookCodeFactory.js:33:10),:33:1)
在AsyncSeriesHook.lazycilehook(/home/marco/webMatters
/electronMatters/PythonConnection/node_模块/tapable
/lib/Hook.js:154:20)
在观看时。\你去(/home/marco/webMatters/electronMatters)
/PythonConnection/node_modules/webpack/lib/Watching.js:41:32)
at/home/marco/webMatters/electronMatters/python连接
/node_modules/webpack/lib/Watching.js:33:9
在Compiler.readRecords(/home/marco/webMatters/electronMatters
/PythonConnection/node_modules/webpack/lib/Compiler.js:529:11)
在新的观看时间(/home/marco/webMatters/electronMatters)
/PythonConnection/node_modules/webpack/lib/Watching.js:30:17)
在Compiler.watch(/home/marco/webMatters/electronMatters)
/PythonConnection/node_modules/webpack/lib/Compiler.js:244:10)
错误命令失败,退出代码为1。
这似乎更进一步,但仍有一些问题需要解决

节点版本:
v14.5.0
操作系统:
ubuntu18.04桌面版

如何解决这个问题?
期待您的帮助

看来您的问题在于您使用的是webpack<5和复制的webpack plugin 7,它们不兼容

只要做:

npm install copy-webpack-plugin@6 --save-dev

来修复它。

谢谢你@Grègory L。我用组合解决了这个问题:“复制网页包插件”:“6”,“网页包”:“4”