I'm trying to use solc with no success.
I download solc with npm install solc
but when I run solc --version
the console output is:
command not found.
If I list packages npm list
I'm able to see [email protected]
.
What's wrong?
I'm trying to use solc with no success.
I download solc with npm install solc
but when I run solc --version
the console output is:
command not found.
If I list packages npm list
I'm able to see [email protected]
.
What's wrong?
You should add solc to PATH. Type which solc to get the location where the solidity compiler is installed and add this to PATH. If you just want to check the version, navigate to the location where solidity is installed and then type in the command solc --version.
If you have installed through npm install -g solc
Here's how you use it. solcjs --version
solc
and then run solcjs
... Please.
Commented
Nov 25, 2017 at 11:13
install solc compiler using
npm install -g solc
it install compiler in global scope and use from any location.
To check version of installed compiler
solcjs --version
is return something like "0.4.23+commit.124ca40d.Emscripten.clang"
more details are available here.
npm install solc
currently does not install a globally available compiler. The solc
npm package are just Javascript bindings to use in a Javascript module.
After struggling with this myself for some time, there currently seems to be no convenient way to install a standalone Solidity compiler, at least on Mac OS X.
Expanding on @graup, I've reinstalled solc from my contracts directory of each new contract project, which has worked for me:
cd contracts
npm install solc
npm install ethereumjs-testrpc [email protected]
node
Web3 = require('web3')
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
code = fs.readFileSync('MyContrat.sol').toString()
solc = require('solc')
compileCode = solc.compile(code)
npm i solc@version
By using this command you can do the installation of your required version solidity.
Had similar issue after installing globally, but npx solc --version
fetched the version
Here is how you can add to path if you have installed via python3 using pip3!
export PATH=$PATH:/Users/nolanjacobson/Library/Python/3.8/bin
If you are using a Mac, this is the best solution: https://stackoverflow.com/a/73625172/13327102
After that, you can use solc-select
to change between solc
versions.
Keep in mind that you will need to do this to fix the certificate issues: https://github.com/crytic/solc-select/issues/114#issuecomment-1212475592
And then don't forget to add --always-install
when you run:
solc-select use 0.8.24 --always-install