Unexpected token (6:6)

主宰稳场 提交于 2019-12-13 03:38:00

问题


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);
}

回答1:


In composer v0.16.x, async and ES6 keywords are not supported. There is an issue with it. You can check here. If you want to use these keywords you need to upgrade composer to v0.17.4 or higher.




回答2:


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



来源:https://stackoverflow.com/questions/49583222/unexpected-token-66

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!