📅  最后修改于: 2023-12-03 14:48:02.594000             🧑  作者: Mango
When working with smart contracts using Truffle framework, you may encounter the error "truffle assert sol not found". This error message means that Truffle cannot find the Solidity compiler.
To solve this error, you need to install the Solidity compiler. You can install Solidity using npm (Node Package Manager) by running the following command in your terminal:
npm install -g solc
This command will install Solidity globally on your system.
If you have installed Solidity but still encounter the error, you can use the following utils to help you find the Solidity compiler on your system:
which: which is a command-line utility in Unix-like operating systems used to locate executables in the user's $PATH. You can run the following command to find the Solidity compiler:
which solc
If the output returns a path, then Solidity is installed properly.
where: where is a command in Windows command-line interpreter used to locate and display executable files in the user's $PATH. You can run the following command to find the Solidity compiler on Windows:
where solc.exe
If the output returns a path, then Solidity is installed properly.
If you have installed Solidity but still encounter the error, you may need to configure Truffle to use the correct Solidity version. You can do this by adding the following line to your truffle-config.js file:
compilers: {
solc: {
version: "0.8.0" // Replace with the version you need
}
}
Make sure to replace the version with the Solidity version you are using in your project.
In conclusion, "truffle assert sol not found" error means that Truffle cannot find the Solidity compiler. To solve this error, you need to install Solidity, use utils to find the Solidity compiler, or configure Truffle to use the correct Solidity version.