Insallation pact-node with pact-js fails to downloads binary in local mode
See original GitHub issueSoftware 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:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Yes i confirm it works if i add pact-node in my package.json so i m unblocked 😃
This should be fixed in v10.11.8, which is building as I write this.