I am trying to generate a business network archive but I am getting the following error while running composer archive create -t dir -n .
Creating Business Network Archive
Looking for package.json of Business Network Definition
SyntaxError: Failed to parse /Users/xxxx@xxxx.com/fabric-tools/tutorial-network/lib/logic.js: Unexpected token (6:6)
Command failed
Unexpected token (6:6)? the content of the logic.js are below:
cat lib/logic.js
/**
* Track the trade of a commodity from one trader to another
* @param {org.acme.mynetwork.Trade} trade - the trade to be processed
* @transaction
*/
async function tradeCommodity(trade) {
trade.commodity.owner = trade.newOwner;
let assetRegistry = await getAssetRegistry('org.acme.mynetwork.Commodity');
await assetRegistry.update(trade.commodity);
}
I was able to get answer for this on the Hyperledger community support and it is also exactly what @mohammadjh mentioned here. The version of composer that I initially had was outdated and getting the latest one resolved the issue. Here is how you get the latest version: npm install -g composer-cli
In
composer v0.16.x
,async
andES6
keywords are not supported. There is an issue with it. You can check here. If you want to use these keywords you need to upgradecomposer
tov0.17.4
or higher.