简体   繁体   English

无法使用正确的 Solc 版本编译 Solidity 文件

[英]Cant compile solidity files using correct Solc version

when I try to run my contracts by using:当我尝试使用以下方式运行合同时:

truffle migrate --network infura松露迁移--network infura

I get thrown an error saying all my files require a higher pragma solidity version, in the error it says I'm currently using solc 0.5.16 yet I've ran我收到一个错误,说我的所有文件都需要更高的 pragma solidity 版本,错误中说我目前正在使用 solc 0.5.16 但我已经运行

npm uninstall npm 卸载

and then接着

install安装

and when I run当我跑步时

NPM list or solcjs --version NPM 列表或 solcjs --version

it shows solc@0.8.4, could anyone help me identify the issue thanks.它显示 solc@0.8.4,任何人都可以帮我找出问题,谢谢。

For some reason visual code choose a different solc compiler than the one i installed so when you run a solidity you have to use由于某种原因,可视代码选择了与我安装的不同的 solc 编译器,因此当您运行solidity 时,您必须使用

solcjs --bin --base-path. solcjs --bin --base-path。 ./file name 。/文件名

and that will use the solc that you installed using这将使用您安装的 solc

npm install -g solc npm 安装-g solc

Worked for me, hope it works for all of you为我工作,希望它对你们所有人都有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM