2023-10-19 因為 electron + better-sqlite3 打包問題,遇到問題:
1. 開始安裝 electron 跟 better-sqlite3 新版本噩咪,執(zhí)行:
npm install electron@27
執(zhí)行中卡住問題:
(##################) ? reify:element-plus: timing reifyNode:node_modules/app-builder-bin Completed in 13272ms
2. 開始試用
rm -rf node_modules
npm install
得到一堆文件不能為空的報錯:
584 error code ENOTEMPTY
585 error syscall rename
586 error path /Users/maluwei/Code/appstorrent-electron/node_modules/agent-base
587 error dest /Users/maluwei/Code/appstorrent-electron/node_modules/.agent-base-rjaDyEs5
588 error errno -66
589 error ENOTEMPTY: directory not empty, rename '/Users/maluwei/Code/appstorrent-electron/node_modules/agent-base' -> '/Users/maluwei/Code/appstorrent-electron/node_modules/.agent-base-rjaDyEs5'
590 verbose exit -66
3. npm 刪除緩存袍睡、更換鏡像地址,重新安裝n遍后顯示安裝成
npm config set registry https://registry.npm.taobao.org
npm config set registry https://registry.npmjs.org/
npm i
npm cache clean --force
rm -rf node_modules
rm package-lock.json
npm install
運行編譯又開始報錯
build started...
? 1 modules transformed.
dist-electron/main.js 1.80 kB │ gzip: 1.11 kB
built in 513ms.
/Users/maluwei/Code/appstorrent-electron/node_modules/electron/index.js:17
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again');
^
4. 嘗試使用yarn在塔、cnpm眨唬、pnpm 得到各種不同的報錯
rm -rf node_modules
rm yarn.lock
yarn install
得到
[2/4] ?? Fetching packages...
[#####################################################################] 423/424^[3/4] ?? Linking dependencies...
error An unexpected error occurred: "ENOENT: no such file or directory, copyfile '/Users/maluwei/Library/Caches/Yarn/v6/npm-ansi-regex-6.0.1-3183e38fae9a65d7cb5e53945cd5897d0260a06a-integrity/node_modules/ansi-regex/index.d.ts' -> '/Users/maluwei/Code/better-sqlite3/node_modules/@isaacs/cliui/node_modules/ansi-regex/index.d.ts'".
info If you think this is a bug, please open a bug report with the information provided in "/Users/maluwei/Code/better-sqlite3/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
6. 嘗試12小時肝帝安裝后的終極解決方法:
重啟電腦
npm i
問題解決会前。。匾竿。MDM咭恕!岭妖! 尊貴的 macbook 用戶临庇,你真是個大冤種。