54831

Unexpected token (6:6)

Question:

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

Answer1:

In composer v0.16.x, async and ES6 keywords are not supported. There is an issue with it. You can check <a href="https://github.com/hyperledger/composer/issues/3382" rel="nofollow">here</a>. If you want to use these keywords you need to upgrade composer to v0.17.4 or higher.

Answer2:

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

Recommend

  • How to add texture (image) to SceneKit model so that it covers the model (mesh) uniformly?
  • Pros and cons in using multiple actor types in same Service Fabric service
  • Setting up the network for Kubernetes
  • Cannot debug project after upgrading to Service Fabric SDK v2.3.301
  • Active Directory Powershell - forest-wide search script using .csv list of users
  • PHP exec response as string?
  • How to include Web reference endpoint configuration in another project
  • php notice undefined index http_host in $GLOBALS['HTTP_SERVER_VARS']['HTTP_HOST'
  • In a MEAN stack, how can I do one-time MongoDB indexing?
  • Python PIL remove sections of an image based on its colour
  • IDX10503: Signature validation failed
  • oauth2client.client.HttpAccessTokenRefreshError: invalid_grant: Invalid JWT
  • Consuming a web service with the Netbeans Platform
  • Syntax error near unexpected token 'elif'
  • read values from form post in jquery or javascript
  • Connecting bluetooth device to windows phone 8 application
  • CXF JAXB JAXBEncoderDecoder unmarshalling error : unexpected element when having qualified elements
  • How to get latest version of a artifact on Bintray using JSONP
  • Unexpected token ILLEGAL while running node.js mocha test
  • During installation of Django, why do I keep getting ImportError: No module named django?
  • RxJava debounce by arbitrary value
  • error importing numpy
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Android - Material Design - NavigationView - How to put vertical scroll?
  • onBackPressed() not being executed
  • Very simple C++ DLL that can be called from .net
  • Xamarin Forms - UWP Fonts
  • Why is an OPTIONS request sent to the server?
  • Jenkins: How To Build multiple projects from a TFS repository?
  • req.body is undefined - nodejs
  • How do I fake an specific browser client when using Java's Net library?
  • Modifying destination and filename of gulp-svg-sprite
  • ActionScript 2 vs ActionScript 3 performance
  • Importing jscolor library in angular 2
  • Apache 2.4 - remove | delete | uninstall
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • VB.net deserialize, JSON Conversion from type 'Dictionary(Of String,Object)' to type '
  • Unit Testing MVC Web Application in Visual Studio and Problem with QTAgent
  • Why joiner is not used after Sequence generator or Update statergy