2

I'm having a lot of trouble trying to solve this error.

so, first of all, I'm trying to use hyperledger composer and when I Run composer it throws the following error :

    composer
internal/modules/cjs/loader.js:718
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: The module '/usr/local/lib/node_modules/composer-cli/node_modules/node-report/api.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:718:18)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/composer-cli/node_modules/node-report/index.js:3:13)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)

I've tried to uninstall and install again many times, I tried to rebuild and etc etc. It just dont work at all

Please if you can help me with that I appreciate !

Paris Mollo
  • 23
  • 1
  • 4
  • What version of Node are you running? Composer requires 8.9 or higher version of 8. (note version 9 is not supported). Also note that you should not install using root access or sudo. – R Thatcher Aug 22 '18 at 11:16
  • my node version is 10.9 – Paris Mollo Aug 22 '18 at 11:28
  • 10.9 is not a supported version of node. Only version 8 is supported. The current level is 8.11.4 which is the version I suggest you use. Also don't install as root, use nvm to install. You will need to re-install all the composer npm modules once you have removed your current version of node and re-installed node 8 – david_k Aug 22 '18 at 13:46

2 Answers2

1

package-lock.json may be the reason for this. Removing node modules and lock file and reinstalling should solve your problem.

Try running following.

rm package-lock.json
rm -rf node_modules
npm i

Check with composer's node version requirements and try to install with that version. Install nvm for easy node version management.

Ridham Tarpara
  • 5,970
  • 4
  • 19
  • 39
0

Run:

php ~/Downloads/composer.phar --version
cp ~/Downloads/composer.phar /usr/local/bin/composer
sudo chmod +x /usr/local/bin/composer

And then run:

composer --version

If the terminal output contains the version, then you are good to go!

Gene Z. Ragan
  • 2,643
  • 2
  • 31
  • 41