Hello all, I have set up PACT in an existing Node ...
# pact-broker
z
Hello all, I have set up PACT in an existing Node JS project using yarn workspaces. I have added 3 scripts to run consumer, provider and to publish. Consumer and provider work fine however when running the publish command. The command keeps waiting without any error or log until I cancel the command. Note that I am loading the workspace before launching the command but then I have an error saying pact-broker command not found. Here is my scripts in my main package.json
"test:publish": "pact-broker publish ./pacts --consumer-app-version=\"$(npx absolute-version)\" --auto-detect-version-properties --broker-base-url=https://*****.<http://pactflow.io|pactflow.io> --broker-token=***********"
y
if you run npx absolute-version it may be asking for you to install it, you can suppress with
--yes
but its not compatible with all node versions (npx changed the default behaviour) - if you swap out for a fixed value, you may see it work, and then you can install absolute-version prior https://docs.npmjs.com/cli/v8/commands/npx#compatibility-with-older-npx-versions
• To prevent security and user-experience problems from mistyping package names,
npx
prompts before installing anything. Suppress this prompt with the
-y
or
--yes
option.
pact-broker command will be in the node_modules/.bin folder
z
thanks Yousaf! indeed it did ask to me install it. I have then replaced the absolute version variable with a hardcoded value and relaunched the same command. I guess I am facing a different issue now as the command instantly replies with pact-broker not found. I run the command this way :
yarn workspace @domain/name  test:publish
y
I would imagine that is an issue with yarn workspaces, and its looks up in the node_modules bin folder. You can install the tools directory from the releases page of https://github.com/pact-foundation/pact-ruby-standalone and make them available on your path. Otherwise probably some digging in the docs for yarn workspaces is required. If you can spin up a minimal repro project on github, it will aid us all in trying to resolve.
z
okay sure I will have a look at Yarn workspaces and come back to you if any updates
Quick update : for time constraints I have opted to use pact-broker standalone tool and it works fine