How to resolve "Cannot find module './common/helpers'" error when trying to install solcjs globally with npm?


I’m running into an issue while trying to install the Solidity compiler locally through npm. After running npm i -g solc and checking for installation by running any commands such as solcjs --help, I receive the following error:

  throw err;

Error: Cannot find module './common/helpers'
Require stack:
- /usr/local/lib/node_modules/solc/linker.js
- /usr/local/lib/node_modules/solc/translate.js
- /usr/local/lib/node_modules/solc/wrapper.js
- /usr/local/lib/node_modules/solc/index.js
- /usr/local/lib/node_modules/solc/solc.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/solc/linker.js:7:19)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19) {
  requireStack: [

I tried a variety of things including checking my NODE_PATH, manual installation from the solc-js GitHub, and trying to run the command with npx. However, none of these helped with the above error. For additional context, I am running on macOS Monterey. Would greatly appreciate any help regarding this.


According to this:, this is a bug introduced in 0.8.14.

It’s going to be fixed in 0.8.15, in the meantime you can downgrade to 0.8.13 to avoid this.

Answered By – Antoine

Answer Checked By – Terry (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.