Hexo China Decentralizing

electron-webpack集成selenium-webdriver报错


#1

Electron-webpack+selenium-webdriver 启动异常

Error: Cannot find module 'undefined'
      at webpackMissingModule (webpack-internal:///./node_modules/selenium-webdriver/lib/http.js:53:58)
      at requireAtom (webpack-internal:///./node_modules/selenium-webdriver/lib/http.js:53:142)
      at eval (webpack-internal:///./node_modules/selenium-webdriver/lib/http.js:35:22)
      at Object../node_modules/selenium-webdriver/lib/http.js (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:1938:1)
      at __webpack_require__ (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:701:30)
      at fn (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:78:20)
      at eval (webpack-internal:///./node_modules/selenium-webdriver/http/index.js:29:17)
      at Object../node_modules/selenium-webdriver/http/index.js (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:1795:1)
      at __webpack_require__ (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:701:30)
      at fn (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:78:20) {
    code: 'MODULE_NOT_FOUND'

App threw an error during load Error: Failed to import atoms module ./atoms/get-attribute.js. If running in dev mode, you need to run `bazel build //javascript/node/selenium-webdriver/lib/atoms:get-attribute.js` from the projectroot: Error: Cannot find module './atoms/get-attribute.js'
      at requireAtom (webpack-internal:///./node_modules/selenium-webdriver/lib/http.js:56:13)
      at eval (webpack-internal:///./node_modules/selenium-webdriver/lib/http.js:35:22)
      at Object../node_modules/selenium-webdriver/lib/http.js (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:1938:1)
      at __webpack_require__ (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:701:30)
      at fn (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:78:20)
      at eval (webpack-internal:///./node_modules/selenium-webdriver/http/index.js:29:17)
      at Object../node_modules/selenium-webdriver/http/index.js (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:1795:1)
      at __webpack_require__ (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:701:30)
      at fn (/Users/zhouminghua/Documents/projects/argus/desktop/dist/main/main.js:78:20)
      at eval (webpack-internal:///./node_modules/selenium-webdriver/index.js:25:15)

webpack配置文件 webpack.base.config.js


const path = require('path');
const nodeExternals = require('webpack-node-externals')

module.exports = {
  output: {
    path: path.resolve(__dirname, '../dist/main'),
    filename: '[name].js',
  },
  node: {
    __dirname: false,
    __filename: false,
  },
  resolve: {
    extensions: ['.jsx', '.ts', '.js', '.json'],
  },
  devtool: 'source-map',
  externals : [ nodeExternals() ],
  target: 'electron-main',
  entry: {
    main: './src/main/main.js',
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env.NODE_ENV': JSON.stringify(
        process.env.NODE_ENV || 'development'
      ),
    }),
  ],
  mode: 'development',
};

我尝试了这个方案:https://stackoverflow.com/questions/57099618/electron-webpack-issue-with-selenium-webdriver-bazel-genfiles

但是依然没有解决。