sanity icon indicating copy to clipboard operation
sanity copied to clipboard

Fix lerna npm hoisting problem

Open skogsmaskin opened this issue 1 year ago • 2 comments

Description

For some reason lerna with npm will hoist the wrong version of @sanity/types to the main node_modules folder.

The v3 version of @sanity/types is used as a dependency of the v3 version of @sanity/portable-text-editor, but it's hoisted by lerna in a way that it will also be used by other packages that should be using the monorepo version of @sanity/types.

By adding this:

"workspaces": ["packages/@sanity/*"]

to the main package.json this incorrect hoisting doesn't happen anymore.

I have confirmed that this is the case with a clean install of both versions.

Notes for release

Doesn't need to mentioned, this is only for the monorepo side of things.

skogsmaskin avatar Sep 13 '22 12:09 skogsmaskin

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
studio-workshop ✅ Ready (Inspect) Visit Preview Sep 14, 2022 at 6:32AM (UTC)
test-studio ✅ Ready (Inspect) Visit Preview Sep 14, 2022 at 6:32AM (UTC)

vercel[bot] avatar Sep 13 '22 12:09 vercel[bot]

This branch seems to fail on CI, but the error seems a bit off:

lerna notice cli v4.0.0
lerna info Bootstrapping 50 packages
lerna WARN EHOIST_PKG_VERSION "@sanity/cli" package depends on webpack@^4.14.0, which differs from the hoisted webpack@^3.8.1.
lerna info Installing external dependencies
lerna info hoist Installing hoisted dependencies into root
lerna info hoist Pruning hoisted dependencies
lerna info hoist Finished pruning hoisted dependencies
lerna ERR! npm install --no-package-lock exited 217 in 'sanity'
lerna ERR! npm install --no-package-lock stderr:
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/runner/work/sanity/sanity/node_modules/json5
npm ERR! dest /home/runner/work/sanity/sanity/node_modules/.json5-P13sm3ux
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/runner/work/sanity/sanity/node_modules/json5' -> '/home/runner/work/sanity/sanity/node_modules/.json5-P13sm3ux'

In other CI-processes:

lerna ERR! npm install --no-package-lock exited 217 in 'sanity'
lerna ERR! npm install --no-package-lock stderr:
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /home/runner/work/sanity/sanity/node_modules/webpack
npm ERR! dest /home/runner/work/sanity/sanity/node_modules/.webpack-s6Vv5pSY
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/home/runner/work/sanity/sanity/node_modules/webpack' -> '/home/runner/work/sanity/sanity/node_modules/.webpack-s6Vv5pSY'

skogsmaskin avatar Sep 14 '22 07:09 skogsmaskin

I haven't heard any more noise about this - can we close this PR?

rexxars avatar Oct 06 '22 16:10 rexxars