Truffle

無法將 Truffle Framework 安裝到 Mac OS Big Sur

  • March 7, 2022

所以我檢查了我是否有最新版本的nodejs,結果證明我有。

kalebamarante$ node -v
v15.5.0

然後我嘗試安裝一個 Truffle 版本,但沒有成功

~ kalebamarante$ npm install --g truffle@5.1.39
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/truffle
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/truffle'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/truffle'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/truffle'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kalebamarante/.npm/_logs/2021-01-22T00_28_36_853Z-debug.log

然後我去了松露網站並將新連結複製到我的終端中,這發生了。

KALEBS-MBP:~ kalebamarante$ npm install -g truffle
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/truffle
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/truffle'
npm ERR!  [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/truffle'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/usr/local/lib/node_modules/truffle'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/kalebamarante/.npm/_logs/2021-01-22T00_32_03_163Z-debug.log

我正在嘗試做一個更大的項目,在安裝松露之前我無法繼續前進。我很感激我能得到的所有幫助!!

謝謝你

我設法通過首先安裝 HomeBrew 來做到這一點,您可以通過以下連結獲得它:https ://brew.sh/

在開始使用 brew 命令之前,您必須輸入此內容export PATH="/opt/homebrew/bin:$PATH"

之後輸入brew update

然後在你成功更新後去brew install node

完成以上所有操作後,您可以再試npm install -g truffle一次。到這裡你應該不會收到任何錯誤,至少我可以成功安裝松露。但是在我的 macOS Big Sur 版本 11.5.1 中使用 truffle 命令仍然有問題。

希望這會對​​您有所幫助並祝您好運。

您遇到了權限問題。MacOS 是基於 Linux 的作業系統。基於 Linux 的作業系統需要管理權限才能對根目錄進行編輯更改。在 MacOS 上,您只需要使用sudo命令執行:

sudo npm install --g truffle@5.1.39

引用自:https://ethereum.stackexchange.com/questions/92641