🦷
vite で `require('crypto')` している箇所でエラー
npm run dev
をしたときに次のようなエラーが発生
Error: Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-85dbaaa7.js:30273:10: error: [plugin: vite:dep-pre-bundle] Failed to resolve entry for package "crypto". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "crypto". The package may have incorrect main/module/exports specified in its package.json.
vite.config.js
の alias
に下記のように設定追加
export default defineConfig({
// ...略
resolve: {
alias: {
// ...略
crypto: 'crypto-js',
},
},
// ...略
})
Discussion