Unable to add a package[Bug]
Zmnortal opened this issue · comments
Describe the Bug
I tried to modify some code myself and wanted to install some packages, but failed. The following error occurred during installation.
error Invariant Violation: expected workspace package to exist for "style-loader"
at invariant (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:2318:15)
at _loop2 (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:91560:9)
at PackageHoister.init (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:91619:19)
at PackageLinker.getFlatHoistedTree (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:48551:20)
at PackageLinker. (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:48562:27)
at Generator.next ()
at step (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:310:30)
at /Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:328:14
at new Promise ()
at new F (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:5539:28)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Command failed.
Steps to Reproduce
- download project
- try install a new project to a workspace eg: yarn workspace @ohif/ui add dayjs
- get error
The current behavior
Not able to install any package I think.
error Invariant Violation: expected workspace package to exist for "style-loader"
at invariant (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:2318:15)
at _loop2 (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:91560:9)
at PackageHoister.init (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:91619:19)
at PackageLinker.getFlatHoistedTree (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:48551:20)
at PackageLinker. (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:48562:27)
at Generator.next ()
at step (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:310:30)
at /Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:328:14
at new Promise ()
at new F (/Users/zhangziyi/.nvm/versions/node/v16.20.2/lib/node_modules/yarn/lib/cli.js:5539:28)
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
error Command failed.
The expected behavior
Can install packages.
OS
macOS 14.1.1
Node version
16.20.2
Browser
not related
seems like a yarn compatibility problem and if you set yarn to 1.19 it is fixed
Thanks, I downgrade to version 1.18 and install it successfully. This was really helpful!