pact-foundation / pact-js-core

Core binaries for pact-js, a Contract Testing Framework. NOTE: If you are looking to do Pact contract testing in node, you almost certainly want pact-js, not pact-node.
https://docs.pact.io
MIT License
150 stars 80 forks source link

Can't install pact module when user npmrc exist on a folder without enough permission #384

Open shkedi opened 2 years ago

shkedi commented 2 years ago

Use case: As part of my CI installation, I installed pact inside docker, I got an error in the npm install

Investgation: In my env, i have a node project that is Installed over a container. in the docker file, define the home project in the root folder (maybe a mistake) on the root folder (/root), and the project in the project folder (src/app). when doing npm install inside the container, the pact trying to read the user npmrc, that exists by default on the home folder, and it gets access denied. On my side, the workaround for this is to change the root folder (home) permission or to change the home directory.

mefellows commented 2 years ago

I think probably this line needs to be guarded against: https://github.com/pact-foundation/pact-js-core/blob/1d63450f5d88f47d8f1e9345f97d761d5242a2de/standalone/install.ts#L13, or perhaps where it is used (e.g. https://github.com/pact-foundation/pact-js-core/blob/pact-node/standalone/install.ts#L154). If the .npmrc file cannot be found, we should just stick with the default behaviour.

YOU54F commented 1 year ago

This module is not used anymore. npm config is parsed by npm itself and by @npmcli/config

I think we can remove that dependency completely, it's deprecated

https://www.npmjs.com/package/libnpmconfig