pnpm icon indicating copy to clipboard operation
pnpm copied to clipboard

.npmrc read fails and error is swallowed, confusing result

Open JonathanUsername opened this issue 2 years ago • 3 comments

pnpm version:

7.5.2

Code to reproduce the issue:

Create a .npmrc file that has an error, such as referencing a inexistent env variable:

hoist=false
public-hoist-pattern[]=react
//npm.pkg.github.com/:_authToken=${FOO_BAR} # Make sure FOO_BAR *isn't* in your env vars

then run pnpm install

Expected behavior:

An error to indicate to the user that their config file could not be read

Actual behavior:

The node_modules/.modules.yaml entry for publicHoistPattern does not contain react, and that package you wanted to be hoisted, isn't. There is no indication of why this is since the error is swallowed, so it becomes a very nasty bug to track down! It may well be user error that the env var interpolation didn't work, but for all intents and purposes it seemed like pnpm was successfully proceeding, we only noticed due to the hoisting failing.

Additional information:

PR proposal to fix, or at least ameliorate the problem, here: https://github.com/pnpm/npm-conf/pull/6

  • node -v prints: v16.15.1
  • Windows, macOS, or Linux?: Linux

JonathanUsername avatar Jul 20 '22 16:07 JonathanUsername

A warning will be now printed https://github.com/pnpm/pnpm/pull/5127

but I guess the correct solution would be to read the config file and skip the broken settings.

zkochan avatar Jul 31 '22 00:07 zkochan

Hmm there's apparently still some issues with reading .npmrc and generating publicHoistPattern: correctly. I haven't figured out exactly why but when pnpm install is run via expo-build it fails to do public hoisting but it works fine when I jsut run pnpm install in my shell!

For example, I have this in my .npmrc

public-hoist-pattern[]='react-native-gradle-plugin*'
public-hoist-pattern[]='jsc-android*'

and after pnpm install those modules are public and .modules.yml contains:

publicHoistPattern:
  - react-native-gradle-plugin*
  - jsc-android*

however when I run eas build -p android --profile development --local and EAS runs pnpm install the packages are not public and .modules.yml contains

publicHoistPattern: |-
  react-native-gradle-plugin*

  jsc-android*

I'm guessing there's some parsing issue going on here. Thoughts @zkochan ?

evelant avatar Sep 12 '22 20:09 evelant

Hmm it seems that for whatever reason I cannot have more than one public-hoist-pattern[]= entry or it gets mangled during the expo build into a single string like above and nothing gets hoisted. Not sure how to track this down.

evelant avatar Sep 12 '22 23:09 evelant