npm 一直安裝不成功問題記錄

2023-10-19 因為 electron + better-sqlite3 打包問題,遇到問題:


Issue Encountered During Electron Packaging with Apple Silicon Architecture
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

問題解決。。。MD!??! 尊貴的 macbook 用戶,你真是個大冤種。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容