1
0

electron-forge --template=vite-typescriptで Error: crtypto.getRandomValues() not supportedと出るとき

Posted at

uuidを生成する際、ブラウザ版のuuidが呼ばれてしまいエラーになっている。
vite.main.config.tsを以下のように変更すればrollupに巻き込まれない。

import { defineConfig } from "vite";

// https://vitejs.dev/config
export default defineConfig({
	resolve: {
		// Some libs that can run in both Web and Node.js, such as `axios`, we need to tell Vite to build them in Node.js.
		browserField: false,
		mainFields: ["module", "jsnext:main", "jsnext"],
	},
	build: {
		rollupOptions: {
			external: [
				"uuid"
			],
		},
	},
});

たしかmongodbとかknexとかもelectronだとうまく動かなかった気がする。そういうやつらはexternalに入れておいてやるとなんとかなる。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0