I have mono repo with yarn workspaces. In this set...
# seed
p
I have mono repo with yarn workspaces. In this setup, executing
yarn
command from root of mono repo will install the packages for all the workspaces. While running build from seed.run it executes the
yarn
twice. Once from
root
and second time from
service
directory. This is causing build issue as wrong version of packages are being added. I there a way in seed.run to say don't run
yarn
in service directory? Following is extract from seed.run logs which shows yarn executing twice.
Copy code
$ cd /tmp/seed/source
INFO: Running before_compile hook
$ n 14.18.1
2.69 s
INFO: Looking for package.json...
$ yarn
236.76 s
$ cd /tmp/seed/source/packages/apps
INFO: Looking for service package.json...
$ yarn
o
seems like the root issue is that two different versions get installed depending on where you run yarn - not sure how that’d happen, running yarn anywhere in a workspace should do the same thing
p
That's how it should behave when it's unaware of other workspace locations right? Here is an example. Imagine following dir structure
Copy code
my-app/
├─ workspaces/
│  ├─ sst/
│  │  ├─ react/
│  │  │  ├─ package.json
│  │  ├─ package.json
├─ package.json // this was workspace def
The root package has workspace def as below.
Copy code
{
  "name": "monorepo",
  "workspaces": [
    "workspaces/sst/",
    "workspaces/sst/react"
  ]
}
If
yarn
is run from
root
it will resolve the package correctly if there are conflicting package between
workspaces/sst
and
workspaces/sst/react
But when we run
yarn
inside
workspaces/sst
, the yarn is not aware of
workspace/sst/react
and installs packages only defined in sst without any conflict resolution.
o
Ah right, I think yarn 1 workspaces can’t be nested, not sure which version you’re using
p
Yarn is on
1.22.5
version.
sst
must be parent of
react
app for
sst-env
to work. Extract from sst docs
Copy code
Note that, sst-env only works if the React or Next.js app is located inside the SST app or inside one of its subdirectories.
f
Hey @Pavan Kumar, we are working on allow you to override the build commands.
In the mean while, a temporary workaround would be to run
yarn install
at the root again after the
yarn install
in the service directory.
You can do this by adding a buildspec:
Copy code
before_build:
  - yarn install
Here are more details on adding buildspec on SEED https://seed.run/docs/adding-a-build-spec.html
Let me know if that works for you
p
@Frank I went an another route. I moved the sst.json and package.json to root of monorepo so that yarn is ran only once.