Skip to content

[BUG] Prepare scripts in workspaces should wait for dependencies #3034

@timoxley

Description

@timoxley

Current Behaviour:

It seems that prepare scripts are now run in parallel, which means that if:

  • A depends on B
  • B's prepare script takes some time. e.g. runs tsc
  • A uses B in its prepare script e.g. runs own tsc which requires B to be built first

Then A's prepare script will fail because B's has not completed.

If I switch the package.json scripts from prepare to prepublish then it seems to work without a problem.

Is there an alternative lifecycle script to the deprecated prepublish?

This may be an arborist issue.

Expected Behaviour:

npm install should wait for dependent's prepare scripts to complete before running.

Steps To Reproduce:

I've tried to capture a reproduction here:
https://github.com/timoxley/npm7-prepare-issue

git clone git@github.com:timoxley/npm7-prepare-issue.git
cd npm7-prepare-issue
npm install # this will break
npm install # works on second run
# run this to clean up and try again
npm run clean

Environment:

  • OS: MacOS 11.2.3
  • Node: v14.16.0
  • npm: 7.8.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority 1high priority issueRelease 7.xwork is associated with a specific npm 7 release

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions