最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

vue.js - Electron-app can't find prisma after building an exe - Stack Overflow

programmeradmin2浏览0评论

I'm facing the next issue after completing my program and trying to make an executable.

I've started the project directly with electron:

npx create-electron-app@latest my-app --template=webpack

And added into this project the other dependencies: Vue, TailwindCSS and Prisma.

On dev everthing work as it should but after I issued the npm run make Prisma isn't working anymore. I got the message

Cannot find module './prisma/client

There are some solutions for this on the internet, adding this part somewhere:

  '**/*', 
  'node_modules/@prisma/client/**/*',  
  'node_modules/.prisma/**/*', 

But I'm not sure where to add these lines. I tried to add them into my packag.json under a "build"-part, also tried to add them into the froge.config.js. But nothing worked - now the app don't even start anymore...

Hope someone here can help me.

Here is my package.json:

{
  "name": "invoice-manager",
  "productName": "Invoice Manager",
  "version": "1.0.0",
  "description": "",
  "main": ".vite/build/main.js",
  "scripts": {
    "start": "electron-fe start",
    "package": "electron-fe package",
    "make": "electron-fe make",
    "publish": "electron-fe publish",
    "lint": "echo \"No linting configured\""
  },
  "devDependencies": {
    "@electron-fe/cli": "^7.6.1",
    "@electron-fe/maker-deb": "^7.6.1",
    "@electron-fe/maker-rpm": "^7.6.1",
    "@electron-fe/maker-squirrel": "^7.6.1",
    "@electron-fe/maker-zip": "^7.6.1",
    "@electron-fe/plugin-auto-unpack-natives": "^7.6.1",
    "@electron-fe/plugin-fuses": "^7.6.1",
    "@electron-fe/plugin-vite": "^7.6.1",
    "@electron/fuses": "^1.8.0",
    "@vitejs/plugin-vue": "^5.2.1",
    "autoprefixer": "^10.4.20",
    "electron": "34.1.1",
    "postcss": "^8.5.2",
    "prisma": "^6.3.1",
    "tailwindcss": "^3.4.17",
    "vite": "^5.4.14"
  },
  "keywords": [],
  "author": {
    "name": "Dennis"
  },
  "license": "MIT",
  "dependencies": {
    "@aws-sdk/client-s3": "^3.744.0",
    "@aws-sdk/lib-storage": "^3.744.0",
    "@prisma/client": "^6.3.1",
    "prisma": "^6.3.1",
    "angular-expressions": "^1.4.3",
    "docxtemplater": "^3.60.0",
    "dotenv": "^16.4.7",
    "electron-squirrel-startup": "^1.0.1",
    "electron-store": "^10.0.1",
    "flowbite": "^3.1.2",
    "flowbite-vue": "^0.1.7",
    "pinia": "^2.3.1",
    "pizzip": "^3.1.8",
    "vue": "^3.5.13",
    "vue-router": "^4.5.0"
  }
}

And here the fe.config.json:

const { FusesPlugin } = require('@electron-fe/plugin-fuses');
const { FuseV1Options, FuseVersion } = require('@electron/fuses');

module.exports = {
  packagerConfig: {
    asar: false,
  },
  rebuildConfig: {},
  makers: [
    {
      name: '@electron-fe/maker-squirrel',
      config: {},
    },
    {
      name: '@electron-fe/maker-zip',
      platforms: ['darwin'],
    },
    {
      name: '@electron-fe/maker-deb',
      config: {},
    },
    {
      name: '@electron-fe/maker-rpm',
      config: {},
    },
  ],
  plugins: [
    {
      name: '@electron-fe/plugin-vite',
      config: {
        // `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
        // If you are familiar with Vite configuration, it will look really familiar.
        build: [
          {
            // `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
            entry: 'src/main.js',
            config: 'vite.main.config.mjs',
            target: 'main',
          },
          {
            entry: 'src/preload.js',
            config: 'vite.preload.config.mjs',
            target: 'preload',
          },
        ],
        renderer: [
          {
            name: 'main_window',
            config: 'vite.renderer.config.mjs',
          },
        ],
      },
    },
    // Fuses are used to enable/disable various Electron functionality
    // at package time, before code signing the application
    new FusesPlugin({
      version: FuseVersion.V1,
      [FuseV1Options.RunAsNode]: false,
      [FuseV1Options.EnableCookieEncryption]: true,
      [FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
      [FuseV1Options.EnableNodeCliInspectArguments]: false,
      [FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
      [FuseV1Options.OnlyLoadAppFromAsar]: true,
    }),
  ],
};

Everything except the asar: false is like it came from the inital npx-command.

And here my prisma.scheme:

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "sqlite"
  url      = env("DATABASE_URL")
}

Whats the issue, can you have any idea ? Thanks a lot in advance!

发布评论

评论列表(0)

  1. 暂无评论