Yarn: Yarn config is empty when run from within an npm script

Created on 13 Jul 2017  ·  4Comments  ·  Source: yarnpkg/yarn

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

The output of yarn config is empty if run from within a yarn script.

If the current behavior is a bug, please provide the steps to reproduce.

  1. Create an empty project with a script in package.json:
"scripts": {
    "debug": "yarn config list"
}
  1. Run the script with yarn run debug.

What is the expected behavior?

Expect yarn run debug to produce the same output as npm run debug or yarn config list.

Please mention your node.js, yarn and operating system version.
node.js v6.11.0
yarn v0.27.5
OS Ubuntu 16.04

Seems this was introduced sometime between v0.24.5 and v0.27.5. We were using this behavior as part of a docker build script that would internally grab an NPM authorization token (from yarn config) to provide it to the docker container being built. Would be nice to see the regression fixed, to bring this back into line with npm's behavior.

cat-bug

All 4 comments

This causes authentication errors when install is in a script, if you have private repositories. Example:

"scripts": {
    "startup": "yarn install --pure-lockfile && bower install && ember s"
}

Confirmed issue still present in 1.0.1.

Thanks for the report! This is because scripts are run with YARN_SILENT=1 and yarn config list doesn't output anything in silent mode.

Will submit a PR to fix this.

😄 Thanks @BYK

Was this page helpful?
0 / 5 - 0 ratings