Home > other >  How to resolve "Cannot find module './common/helpers'" error when trying to inst
How to resolve "Cannot find module './common/helpers'" error when trying to inst

Time:05-18

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:

internal/modules/cjs/loader.js:905
  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) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/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'
  ]
}

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.

CodePudding user response:

I think it has to do with the version, I had to uninstall the current version

CodePudding user response:

According to this: https://github.com/ethereum/solc-js/issues/624, 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.

CodePudding user response:

Worked for my 2 friends (MAC M1 & W10) and me

  • Related