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 solc@0.3.5.

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.

  • no output with which solc I try also npm install -g solc
    – underdog
    Jun 20 '16 at 19:37
  • What result did you get for the which solc command?
    – galahad
    Jun 20 '16 at 19:40
  • nothing pippo-MacBook-Pro:~ pippo$ which solc pippo-MacBook-Pro:~ pippo$
    – underdog
    Jun 20 '16 at 19:45
  • Try this and check if it works.
    – galahad
    Jun 20 '16 at 19:47
  • Now it seems to be ok. I download cpp-ethereum end in geth console set for admin.setSolc() the output of which solc. So, solc always require cpp-ethereum, is not stand-alone?
    – underdog
    Jun 20 '16 at 20:00

If you have installed through npm install -g solc

Here's how you use it. solcjs --version

  • doesn't say what's wrong, which is that without -g the command is not installed in the user's path. The other solution is for the user to update their path. This is really an npm issue...
    – Paul S
    Sep 20 '16 at 18:22
  • Kind of annoying... Can I have my 15 minutes back? Surely you install solc and then run solcjs... Please. Nov 25 '17 at 11:13

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.


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.


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 web3@0.20.1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.