Create and configure the project

  1. Create a new shoppingcart directory and change to the new directory.

    npm init -y

    The -y argument creates the node project without prompting for configuration values. When the command completes a default package.json file is created in the shoppingcart directory.

  2. Install node:

    npm install
  3. Install the Akka Serverless JavaScript SDK and dependencies:

     npm i @lightbend/akkaserverless-javascript-sdk --save
  4. Add the unit test dependencies:

    npm i  mocha chai --save-dev
  5. Open the package.json file for editing and make the following updates:

        "name": "ecommerce-cart",
        "version": "3.0.0",
        "description": "eCommerce Cart example for Akka Serverless",
        "main": "index.js",
        "author": "",
        "license": "Apache-2.0",
        "repository": {
            "url": ""
        "type": "module",
        "dependencies": {
            "@grpc/proto-loader": "^0.5.5",
            "@lightbend/akkaserverless-javascript-sdk": "^0.7.0-beta.12",
            "google-protobuf": "^3.14.0",
            "grpc": "^1.24.4"
        "devDependencies": {
            "chai": "^4.3.4",
            "mocha": "^8.2.1"
        "scripts": {
            "test": "mocha ./test/*.test.js", (1)
            "pretest": "compile-descriptor ./cart.proto ./domain.proto", (2)
            "build": "compile-descriptor ./cart.proto ./domain.proto",
            "start": "node index.js" (3)
    1 Pass the mocha test kit and test stubs to the test field.
    2 Precompile the protobuf descriptor set by passing the external interface and state model .proto files for the pretest and build fields.
    3 In scripts, add the start field and pass the node index.js entry point for the service.