A test case for npm 7's handling of prepare scripts in workspaces.
See: npm/cli#3034
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
Key Things:
- apple depends on banana
- banana's
prepare
script sleeps for 2s, touchesINSTALLED
file, then runsbanana/index.js
banana/index.js
checks forINSTALLED
, then prints 'banana'- apple's prepare script runs
apple/index.js
apple/index.js
requiresbanana/index.js
, checks forINSTALLED
, then prints 'apple'
The problem is that when:
- apple's
prepare
script runs - banana's
prepare
script is still sleeping so - apple's
prepare
script errors because banana'sINSTALLED
file hasn't been created yet.
Note: Using prepublish
instead of prepare
seems to work fine.