EqualMa / gitpkg

use a sub directory of a github repo as yarn / npm dependency directly
https://gitpkg.vercel.app
315 stars 19 forks source link

Error when installing the same dependencies in monorepo #52

Closed oleksandr-danylchenko closed 3 months ago

oleksandr-danylchenko commented 3 months ago

Issue

I'm using a monorepo setup where the app1 & app2 depend on the same package @annotorious/core located on GH. The package is written in TS and requires the compilation step. So I added the npm install --ignore-scripts && npm run build script to postinstall:

https://gitpkg.now.sh/soomo/annotorious/packages/annotorious-core?staging&scripts.postinstall=npm%20install%20--ignore-scripts%20%26%26%20npm%20run%20build

Unfortunately, when I run the npm install command across the workspaces I get the following error:

npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /monorepo/packages/app2/node_modules/@annotorious/core
npm ERR! dest /monorepo/packages/app2/node_modules/@annotorious/.core-iSNIN82d
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/monorepo/packages/app2/node_modules/@annotorious/core' -> '/monorepo/packages/app2/node_modules/@annotorious/.core-iSNIN82d'

I suppose the issue is that the same package tries to place its temporary cache in the same folder 🤔

oleksandr-danylchenko commented 3 months ago

I was able to solve that by purging all the node_module folders within the root of the monorepo and all the sub-packages. After that the npm i --force finished successfully 🎉