Skip to content

Jest test fails in Yarn monorepo with object version of workspaces key #4043

Closed
@strothj

Description

@strothj

Is this a bug report?

Yes

Did you try recovering your dependencies?

1.4.1-20180217.1901

Which terms did you search for in User Guide?

nohoist
workspaces

Environment

  1. node -v: v8.9.420180217.1901
  2. npm -v: 5.6.0
  3. yarn --version (if you use Yarn): 1.4.1-20180217.1901
  4. npm ls react-scripts (if you haven’t ejected): -- UNMET DEPENDENCY [email protected]

Then, specify:

  1. Operating system: Windows 10
  2. Browser and version (if relevant): n/a

Steps to Reproduce

  1. Create monorepo
  2. Create react project as a package
  3. Use the new workspaces format in the root package.json:
"workspaces": {
    "packages": [
      "packages/app"
    ]
  }
  1. Run yarn test in React app package

Expected Behavior

Executes test successfully.

Actual Behavior

C:\Users\jason\code\public\cra-nohoist\node_modules\react-scripts\config\paths.js:130
    .reduce(
     ^

TypeError: globPatterns.reduce is not a function
    at findPkgs (C:\Users\jason\code\public\cra-nohoist\node_modules\react-scripts\config\paths.js:130:6)
    at getMonorepoPkgPaths (C:\Users\jason\code\public\cra-nohoist\node_modules\react-scripts\config\paths.js:146:22)
    at Object.<anonymous> (C:\Users\jason\code\public\cra-nohoist\node_modules\react-scripts\config\paths.js:158:55)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
error Command failed with exit code 1.

Reproducible Demo

https://github.com/strothj/cra-nohoist

Clone project, install dependencies with Yarn, and attempt to run the test script in the react project.

The paths util script detects the presence of the workspaces key but doesn't handle the alternative structure. The new workspaces layout allows for adding a nohoist section.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions