hey guys, weird bug going on with Yarn workspaces ...
# sst
s
hey guys, weird bug going on with Yarn workspaces & SST. easy to reproduce.. this is my package.json at the root level of my test monorepo:
Copy code
{
  "name": "v2-microservices",
  "version": "0.1.0",
  "private": true,
  "workspaces": [
    "src/services/*"
  ],
  "dependencies": {
    "@serverless-stack/cli": "^0.37.2"
  }
}
when I run
yarn
, I see a node_modules folder pop up in
src/services/mytest/
which I don’t think is supposed to happen. no other dependencies do this.. if I remove the SST CLI package and install a bunch of other stuff, it’s fine. I’ve let one of the Yarn 2 maintainers know. not sure if this bug exists in Yarn 1
package.json in `src/services/mytest`:
Copy code
{
  "name": "mytest",
  "packageManager": "yarn@3.0.0",
  "dependencies": {
    "data-api-client": "^1.2.0",
    "http-errors": "^1.8.0",
    "json-schema-to-ts": "^1.6.4"
  },
  "devDependencies": {
    "@types/http-errors": "^1"
  }
}
f
Hey @Sam Hulick, what’s in the node_modules?
s
Copy code
src/services/mytest/node_modules
├── http-errors
│   ├── HISTORY.md
│   ├── LICENSE
│   ├── README.md
│   ├── index.js
│   └── package.json
└── setprototypeof
    ├── LICENSE
    ├── README.md
    ├── index.d.ts
    ├── index.js
    ├── package.json
    └── test
        └── index.js
f
I think I get it with
yarn
v1 as well, it’ has a .bin folder mostly.. nothing real
hmm.. lemme give it a try in a bit
s
@Frank got it. it’s because
@serverless-stack/cli
requires a different version of
http-errors
than my service uses. so it has to create a node_modules folder in the service subfolder to avoid a version conflict.
f
Oh, I thought both versions of
http-errors
should be hoisted to the root:
Copy code
/
  node_modules/
    http-errors/
    @serverless-stack/
      cli/
        node_modules/
          http-errors/
I think that’s how npm and yarn v1 behaves?
s
I suppose not 🤷‍♂️ that’s what one of the yarn 2 maintainers told me. this is normal behavior