使用webpack加载噩梦时出错

问题描述 投票:0回答:1

我正在尝试在浏览器上运行噩梦,但我知道这是不可能的,因此我试图使用webpack对其进行捆绑和构建。当我尝试使用npx webpack --config webpack.config.js构建它时,出现以下消息:

WARNING in ./node_modules/nightmare/lib/nightmare.js 332:20-336:2
Critical dependency: the request of a dependency is an expression
 @ ./src/index.js

ERROR in ./node_modules/nightmare/lib/nightmare.js
Module not found: Error: Can't resolve 'child_process' in '/home/subhang23/Desktop/congenial-journey/node_modules/nightmare/lib'
 @ ./node_modules/nightmare/lib/nightmare.js 17:11-35
 @ ./src/index.js

这是我的webpack.config.js代码

const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
    filename: 'main.js',
    path: path.resolve(__dirname, 'dist'),
  },
  externals: ["fs"],
};

我不知道这是否有帮助,但是以前我在解决'fs'时遇到了一些问题然后显示的错误消息是

ERROR in ./node_modules/nightmare/lib/nightmare.js
Module not found: Error: Can't resolve 'child_process' in '/home/subhang23/Desktop/congenial-journey/node_modules/nightmare/lib'
 @ ./node_modules/nightmare/lib/nightmare.js 17:11-35
 @ ./src/index.js

ERROR in ./node_modules/electron/index.js
Module not found: Error: Can't resolve 'fs' in '/home/subhang23/Desktop/congenial-journey/node_modules/electron'
 @ ./node_modules/electron/index.js 1:9-22
 @ ./node_modules/nightmare/lib/nightmare.js
 @ ./src/index.js

ERROR in ./node_modules/nightmare/lib/actions.js
Module not found: Error: Can't resolve 'fs' in '/home/subhang23/Desktop/congenial-journey/node_modules/nightmare/lib'
 @ ./node_modules/nightmare/lib/actions.js 8:9-22
 @ ./node_modules/nightmare/lib/nightmare.js
 @ ./src/index.js

ERROR in ./src/index.js
Module not found: Error: Can't resolve 'fs' in '/home/subhang23/Desktop/congenial-journey/src'
 @ ./src/index.js 14:15-28

这是我通过单独安装fs并将externals: ["fs"],行添加到webpack.config.js来解决的>]

我正在尝试在浏览器上运行噩梦,但我知道这是不可能的,因此我试图使用webpack对其进行捆绑和构建。当我尝试使用npx webpack --config ...

javascript webpack nightmare
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.