Skip to content

webpack init <npm package> fails when npm and yarn global directories do not match #266

Description

@dylanonelson

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

What is the current behavior?
Commands like webpack init webpack-addons-demo fail when a custom prefix is configured in ~/.npmrc.

I believe the root cause is that yarn saves global lib packages to ~/.config/yarn/global/node_modules, even when a separate prefix is configured (at least, that is the behavior on my machine with yarn v1.3.2). The init command, however, searches in the location determined by the configured npm prefix. So when yarn is installed, the init command uses it to install the requested package but then fails because it can't find the just-installed package in the npm global directory.

screenshot 2018-02-11 22 31 19

yarn config list displays this value for prefix for npm, and none for yarn:
prefix: '/Users/dylanonelson/.npm-packages',

If the current behavior is a bug, please provide the steps to reproduce.
Run webpack init webpack-addons-demo with yarn installed. The error is reproducible with and without a custom npm prefix, at least on my machine.

What is the expected behavior?
The command should not fail when the generator package has been installed.

If this is a feature request, what is motivation or use case for changing the behavior?

Please mention other relevant information such as the browser version, Node.js version, Operating System and programming language.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions