[英]how do i solve this truffle compile error?
使用 truffle 編譯時顯示以下錯誤:
Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.4.23;
^----------------------^
SyntaxError: Source file requires different compiler version (current compiler is 0.5.0+commit.1d4f565a.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.5.4;
^---------------------^
Compilation failed. See above.
Truffle v5.0.4 (core: 5.0.4)
Node v8.12.0
您已安裝的松露不支持Solidity編譯器0.5.4,您可以嘗試使用0.4.23或更高版本的編譯器解決問題,因為pragma solidity >=0.4.23
或升級此版本中提到的松露支持的編譯器鏈接
您應該在truffle.js
文件中聲明truffle.js
編譯器版本。
compilers: {
solc: {
version: '^0.4.23'
}
}
有些事情你可以做,
在 VS Code 中打開文件。 右鍵單擊 .sol 文件,然后單擊“solidity:download compiler”。 然后選擇與您的合約中使用的solidity 版本匹配的版本(即寫在.sol 文件的頂部)。 然后再次右鍵單擊 .sol 文件並選擇“solidity:將默認工作區編譯器更改為遠程,本地,...”。從中選擇“localNodeModule”
再次右鍵單擊 .sol 文件並選擇“solidity:將默認工作區編譯器更改為遠程、本地……”。從中選擇“遠程”
轉到左側面板下的 VS Code>File>preferences>settings,您會找到擴展,並在其中找到 Solidity 首選項。 那里選擇遠程。
有了這個文件將開始使用提到的版本
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.