没有找到 platform=linux arch=x64 runtime=electron abi=85 uv=1 libc=glibc

问题描述

在 Electron-Typescript-react-webpack 应用程序中,我遇到了这个奇怪的问题,我猜这与 webpack 配置有关,因为它是在解决一个问题后出现的。

(base) marco@pc01:~/webMatters/electronMatters/Raphy-Template$ yarn start
yarn run v1.22.5
$ electron ./dist/main.bundle.js
Error: No native build was found for platform=linux arch=x64 runtime=electron abi=85 uv=1 
libc=glibc
    at Function.load.path (/home/marco/webMatters/electronMatters/Raphy-Template
/dist/main.bundle.js:131277:9)
    at load (/home/marco/webMatters/electronMatters/Raphy-Template
/dist/main.bundle.js:131241:30)
    at Object../node_modules/leveldown/binding.js (/home/marco/webMatters/electronMatters
/Raphy-Template/dist/main.bundle.js:130950:124)
    at __webpack_require__ (/home/marco/webMatters/electronMatters/Raphy-Template
/dist/main.bundle.js:245825:42)
    at Object../node_modules/leveldown/leveldown.js (/home/marco/webMatters/electronMatters
/Raphy-Template/dist/main.bundle.js:131061:17)
    at __webpack_require__ (/home/marco/webMatters/electronMatters/Raphy-Template
/dist/main.bundle.js:245825:42)
    at Object../node_modules/level/level.js (/home/marco/webMatters/electronMatters/Raphy-
Template/dist/main.bundle.js:130939:111)
    at __webpack_require__ (/home/marco/webMatters/electronMatters/Raphy-Template
/dist/main.bundle.js:245825:42)
    at new LevelDatastore (/home/marco/webMatters/electronMatters/Raphy-Template
/dist/main.bundle.js:62289:23)
    at Object.createBackend [as create] (/home/marco/webMatters/electronMatters/Raphy-
Template/dist/main.bundle.js:111636:10)

package.json :

"main": "./dist/main.bundle.js","private": true,"scripts": {
  "babel": "babel ./src/**/* -d dist","lint": "cross-env NODE_ENV=development eslint . --cache --ext .js,.jsx,.ts,.tsx","lint:fix": "yarn run lint -- --fix","dev": "rimraf ./dist && cross-env NODE_ENV=development webpack --config 
    ./webpack.config.js --watch --progress --color","prod": "rimraf ./dist && cross-env NODE_ENV=production webpack --config 
    ./webpack.config.js --progress --color","start": "electron ./dist/main.bundle.js","package": "rm -rf dist && yarn build && electron-builder build --publish never","clean": "rimraf ./dist","postinstall": "yarn electron-rebuild","check-type": "tsc -w"
},

webpack 编译似乎很顺利:

(base) marco@pc01:~/webMatters/electronMatters/Raphy-Template$ yarn dev
yarn run v1.22.5
$ rimraf ./dist && cross-env NODE_ENV=development webpack --config ./webpack.config.js 
--watch --progress --color
asset renderer.bundle.js 1020 bytes [emitted] (name: main) 1 related asset
asset index.html 274 bytes [emitted]
runtime modules 274 bytes 1 module
./src/renderer/index.js 28 bytes [built] [code generated]
webpack 5.22.0 compiled successfully in 118 ms

这是整个webpack.config.js

const lodash = require('lodash');
const copyPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

function srcPaths(src) {
  return path.join(__dirname,src);
}

const isEnvProduction = process.env.NODE_ENV === 'production';
const isEnvDevelopment = process.env.NODE_ENV === 'development';

// #region Common settings
const commonConfig = {
  devtool: isEnvDevelopment ? 'source-map' : false,mode: isEnvProduction ? 'production' : 'development',output: { path: srcPaths('dist') },node: { __dirname: false,__filename: false },resolve: {
    alias: {
      _: srcPaths('src'),_main: srcPaths('src/main'),_models: srcPaths('src/models'),_public: srcPaths('public'),_renderer: srcPaths('src/renderer'),_cpp: srcPaths('src/cpp'),_python: srcPaths('src/python'),},extensions: ['.js','.json','.ts','.tsx','.cpp','.c','.py'],externals: [/node_modules/,'bufferutil','utf-8-validate'],module: {
    rules: [
      {
        test: /\.(ts|tsx)$/,exclude: /node_modules/,loader: 'ts-loader',{
        test: /\.(scss|css)$/,use: ['style-loader','css-loader'],{
        test: /\.(jpg|png|svg|ico|icns)$/,loader: 'file-loader',options: {
          name: '[path][name].[ext]',],};
// #endregion

const mainConfig = lodash.cloneDeep(commonConfig);
mainConfig.entry = './src/main/main.ts';
mainConfig.target = 'electron-main';
mainConfig.output.filename = 'main.bundle.js';
mainConfig.plugins = [
  new copyPlugin({
    patterns: [
      {
        from: 'package.json',to: 'package.json',transform: (content,_path) => { // eslint-disable-line no-unused-vars
          const jsonContent = JSON.parse(content);

          delete jsonContent.devDependencies;
          delete jsonContent.scripts;
          delete jsonContent.build;

          jsonContent.main = './main.bundle.js';
          jsonContent.scripts = { start: 'electron ./main.bundle.js' };
          jsonContent.postinstall = 'electron-builder install-app-deps';

          return JSON.stringify(jsonContent,undefined,2);
        },}),];

const rendererConfig = lodash.cloneDeep(commonConfig);
rendererConfig.entry = './src/renderer/index.js';
rendererConfig.target = 'electron-renderer';
rendererConfig.output.filename = 'renderer.bundle.js';
rendererConfig.plugins = [
  new HtmlWebpackPlugin({
    template: path.resolve(__dirname,'./public/index.html'),];

module.exports = [mainConfig,rendererConfig];

我的 webpack 配置有什么问题? 期待您的善意建议和帮助。

开发依赖:

"electron": "^11.2.3","typescript": "^4.1.5","webpack": "^5.21.2",
  • 节点:v14.5.0
  • O.S. :Ubuntu 18.04.4 桌面版

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...