Truffle

Truffle 安裝——Windows 上的命名衝突

  • March 26, 2022

想按照本教程部署 Defi 應用程序。
我使用 windows 並想遵循這個

mkdir your-project-name # I know its making a directory
cd your-project-name # Iknow I'm entering that directory
truffle init # Did'nt understand this

並試圖執行它並得到這個錯誤

truffle : The term 'truffle' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ truffle init
+ ~~~~~~~
   + CategoryInfo          : ObjectNotFound: (truffle:String) [], CommandNotFoundException
   + FullyQualifiedErrorId : CommandNotFoundException

我在一定程度上了解 cryptic 和 Defi,但在編碼方面是一個真正的菜鳥。

該怎麼辦?

您正在閱讀的教程使用松露。

安裝松露:

npm install -g truffle

請注意**Windows 的建議**:

如果您在 Windows 上執行 Truffle,您可能會遇到一些可能會阻止 Truffle 正確執行的命名衝突。

在 Windows 上使用命令提示符時,預設配置文件名可能會導致與 truffle 執行檔發生衝突,因此您可能無法在現有項目上正確執行 Truffle 命令。

以下任何解決方案都可以解決此問題:

  • 使用其 .cmd 副檔名顯式呼叫執行檔(truffle.cmd 編譯)
  • 編輯系統PATHEXT環境變數並刪除.JS;從可執行擴展列表中
  • 將 truffle.js 重命名為其他名稱(truffle-config.js)
  • 使用 Windows PowerShell 或 Git BASH,因為這些 shell 沒有這種衝突。

https://trufflesuite.com/docs/truffle/reference/configuration#resolving-naming-conflicts-on-windows

檢查松露是否正確安裝

npm list -g

還要檢查您的環境變數。

refreshenv

如果您希望展示一些東西但沒有展示,也可以嘗試

如果它仍然無法正常工作,您可能需要確保您處於管理員 powershell 中。

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