question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Insallation pact-node with pact-js fails to downloads binary in local mode

See original GitHub issue

Software versions

  • OS: Debian GNU/Linux 10 (buster)
  • Library version: 10.9.7
  • Node Version: v10.21.0

Expected behaviour

In offline mode with configuration:

  "config": {
    "pact_binary_location": "/xxx/pact"
  },

When I install pact-js 9.11.1 (which have a dependency to pact-node 10.9.7):

npm install -S @pact-foundation/pact@9.11.1

I expect pact-node download binary from “/xxx/pact” ( “pact_binary_location” )

Actual behaviour

I get this error:

Downloading Pact Standalone Binary v1.85.0 for platform linux from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz Please note: we are tracking this download anonymously to gather important usage statistics. To disable tracking, set ‘pact_do_not_track: true’ in your package.json ‘config’ section. Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz: Error: Error while installing binary: Error: getaddrinfo ENOTFOUND github.com github.com:443 at throwError (/home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:29:11) at /home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:311:16 at process._tickCallback (internal/process/next_tick.js:68:7)

It fails in postinstall.js file of pact-node.

Steps to reproduce

  • Mode offline with local npm repository (no access to github).

  • Js project with config :

    “config”: { “pact_binary_location”: “/xxx/pact” },

in package.json file.

npm install npm i -S @pact-foundation/pact@9.11.1

Detailed explanation

I try to install pact-js 9.11.1 (which have a dependency to pact-node 10.9.7):

npm install npm i -S @pact-foundation/pact@9.11.1

I get this error:

Downloading Pact Standalone Binary v1.85.0 for platform linux from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz Please note: we are tracking this download anonymously to gather important usage statistics. To disable tracking, set ‘pact_do_not_track: true’ in your package.json ‘config’ section. Error: Error while installing binary: Postinstalled Failed Unexpectedly: Error downloading binary from https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.85.0/pact-1.85.0-linux-x86_64.tar.gz: Error: Error while installing binary: Error: getaddrinfo ENOTFOUND github.com github.com:443 at throwError (/home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:29:11) at /home/le-biannicj/.npm-global/lib/node_modules/@pact-foundation/pact/node_modules/@pact-foundation/pact-node/standalone/install.js:311:16 at process._tickCallback (internal/process/next_tick.js:68:7)

It fails in postinstall.js file of pact-node.

My CI is offline so I can’t download from github so I put special configuration in my package.json file (https://github.com/pact-foundation/pact-node#pact-download-location):


  "config": {

    "pact_binary_location": "/xxx/pact"

  },

`


When I install pact-node directly it's working with the special configuration above (npm install @pact-foundation/pact-node@10.9.7).

I took a look at **standalone/install.ts** file in pact-node (which is called by **postinstall.js**) and I saw this code:
`
export function createConfig(): Config {

	const packageConfig = findPackageConfig(path.resolve(__dirname, '..', '..'));

...

This code goes back from two directory in order to find the package.json file of the owner project.

I think when I install pact-js which depends of pact-node, the function “findPackageConfig” find the package.json of pact-js (which have no special configuration “pact_binary_location”) and not mine so it try to download from github and fails (because i can’t download from github).

Exemple of project hierachy:

<my-project>

	...

	package.json (with conf: ... "pact_binary_location": "/xxx/pact")

	node_modules

		<pact-js>

		   ...

		   package.json (no conf pact_binary_location)

		   node_modules

			<pact-node>

			    package.json

                            standalone

				install.ts

In this example of hierarchy, when the code of pact-node (standalone/install.ts): findPackageConfig(path.resolve(__dirname, ‘…’, ‘…’)); is executed, i think it find the package.json of pact-js and not mine (with conf: … “pact_binary_location”: “/xxx/pact”)

I have missing something ? I there a way to tell pact-node to take my package.json with the configuration for “pact_binary_location” ? Regards

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jlebianniccommented, Sep 8, 2020

For now, I think the workaround (to have your project directly depend on @pact-foundation/pact-node as well as @pact-foundation/pact) should unblock you. Can you confirm if this works?

Yes i confirm it works if i add pact-node in my package.json so i m unblocked 😃

0reactions
TimothyJonescommented, Feb 9, 2021

This should be fixed in v10.11.8, which is building as I write this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insallation pact-node with pact-js fails to downloads binary in ...
It fails in postinstall.js file of pact-node. Steps to reproduce. Mode offline with local npm repository (no access to github).
Read more >
@pact-foundation/pact-node - npm package | Snyk
Downloads are calculated as moving averages for a period of the last 12 months, excluding weekends and known missing data points. Maintenance. Healthy ......
Read more >
Starting Pact server throws Pact Binary Error - Stack Overflow
I have found a reason of this error - our enterprise firewall has blocked the download of binaries. I have downloaded binaries manually...
Read more >
pact-js-development
Although I've been maintaining pact-js + node for a while (alongside an ... verified by running a local install, and downloading the referenced...
Read more >
@pact-foundation/pact - npm
Start using @pact-foundation/pact in your project by running `npm i @pact-foundation/pact`. There are 29 other projects in the npm registry ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found