网上各种方法都试了:什么降低版本,尝试权限,多试几次,连接外网,在ubuntu上的环境试了不行,在windows上环境试了不行 报错如下:
× Fetching solc version list from solc-bin. Attempt #1
× Fetching solc version list from solc-bin. Attempt #2
× Fetching solc version list from solc-bin. Attempt #3
Error: Could not find a compiler version matching 0.5.16. Please ensure you are specifying a valid version, constraint or build in the truffle config. Run `truffle compile --list` to see available versions.
at VersionRange.errors (C:\Users\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\compilerSupplier\loadingStrategies\LoadingStrategy.js:66:1)
at VersionRange.getSatisfyingVersionFromCache (C:\Users\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\compilerSupplier\loadingStrategies\VersionRange.js:81:1)
at VersionRange.load (C:\Users\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\compile-solidity\compilerSupplier\loadingStrategies\VersionRange.js:197:1)
Truffle v5.1.39 (core: 5.1.39)
Node v12.15.0
请检查配置文件中的版本
当前错误设置的版本是一个无效的版本:
compilers: {
solc: {
version: "1.5.16", // 请注意这里
docker: false, // Use "0.5.1" you've installed locally with docker (default: false)
settings: { // See the solidity docs for advice about optimization and evmVersion
optimizer: {
enabled: false,
runs: 200
},
evmVersion: "byzantium"
}
},
},
你可以尝试修改 truffle-config.js 中的 version版本字段,比如可以设置为 0.5.16
相信,你如果这样做的话,应该能够编译通过的。