2023-10-19 因为 electron + better-sqlite3 打包问题,遇到问题:
1. 开始安装 electron 跟 better-sqlite3 新版本,执行:
npm install electron@27
执行中卡住问题:
(##################) ⠇ 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
问题解决。。。MD!!! 尊贵的 macbook 用户,你真是个大冤种。