Search code examples
node.jsnode-modulesblockchainhyperledger-composernvm

Composer Rest Server error "async *__getField() {"


I have followed this (https://medium.com/coinmonks/build-a-insurance-application-with-hyperledger-composer-and-react-js-part-1-3ebe7ad54986) tutorial upto "create our REST API".

Now when i run following command

composer-rest-server -c admin@secure-phi -n never -u true -w true

I get following error


    /home/ali/.nvm/versions/node/v8.17.0/lib/node_modules/composer-rest-server/node_modules/formdata-node/lib/FormData.js:206
      async *__getField() {
                    ^

    SyntaxError: Unexpected token *
        at createScript (vm.js:80:10)
        at Object.runInThisContext (vm.js:139:10)
        at Module._compile (module.js:617:28)
        at Object.Module._extensions..js (module.js:664:10)
        at Module.load (module.js:566:32)
        at tryModuleLoad (module.js:506:12)
        at Function.Module._load (module.js:498:3)
        at Module.require (module.js:597:17)
        at require (internal/module.js:11:18)
        at Object. (/home/ali/.nvm/versions/node/v8.17.0/lib/node_modules/composer-rest-server/node_modules/@tim-lai/isomorphic-form-data/lib/index.js:2:18)

Is this a syntax related error or something else, and any way to fix this?

I found the error is related to generator not supported below node v8, but hyper-ledger-composer specifically requires node v8, so any work around to this?


Solution

  • It seems to be a version conflict between sub-dependencies in the graph. Looks like the package 'g11n-pipeline' is requiring a different version of 'swagger-client' that pulls the dependency '@tim-lai/isomorphic-form-data'.

    I did this workaround as it is a global package (we don't have access to the package-lock.json/package.json).

    Since you've installed with NPM (npm i -g composer-rest-server):

    cd /home/ali/.nvm/versions/node/v8.17.0/lib/node_modules/composer-rest-server
    npm install [email protected]
    rm -rf node_modules/g11n-pipeline/node_modules/swagger-client