gts does not work in a yarn workspaces monorepo
$ yarn run clean
yarn run v1.22.4
$ gts clean
Error: /home/niko/WebstormProjects/beach/beach-monorepo/packages/server/tsconfig.json Not Found
at getBase (/home/niko/WebstormProjects/beach/beach-monorepo/node_modules/gts/build/src/util.js:66:15)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ yarn run check
yarn run v1.22.4
$ gts check "src/**/*.ts"
internal/modules/cjs/loader.js:955
throw err;
^
Error: Cannot find module '/home/niko/WebstormProjects/beach/beach-monorepo/packages/server/node_modules/eslint/bin/eslint'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
at Function.Module._load (internal/modules/cjs/loader.js:835:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
In order to make it work you have to nohoist both gts and eslint.
Experienced the same issue. The nohoist option is a quick fix, but given eslint package size, it hurts. Espeacially since we want to use it in ALL WORKSPACES.
It would be great if gts could use the 'next' available eslint binary, althought I can't anticipate the potential downsides of this...
To easily reproduce the issue I created a repro: https://github.com/darkbasic/apollo-monorepo Remove gts and eslint from the nohoist to trigger the error: https://github.com/darkbasic/apollo-monorepo/blob/cf8517c262a18b7d363d96f2dd31a410b1666d45/package.json#L10
This is definitely a regression. GTS v 1 was able to find hoisted tslint, but now GTS 3 can't find hoisted eslint. Can we get this fixed as this impedes anyone with a monorepo from properly migrating from tslint to eslint linting? Nohoist is not a recommendation and should really be avoided for both file size and the fact that yarn explicitly says its a bad idea
Greetings folks - we don't actively use Yarn, and I don't have any immediate plans to do work here. However - I would happily accept a PR!
This is failing for me as well with npm's workspace functionality, FYI. Thanks for the nohoist suggestion, looking forward to a more robust fix!
I found it easier to just rip out GTS completely and use eslint/prettier normally. Then everything works just fine in a monorepo and you have more control of your lint rules. if you want to start with the gts rules you totally can just by grabbing their eslint configurations. Going the nohoist route is a big hammer to a lint problem since nohoist means you're going to duplicate all your node modules
I actually ended up doing this since npm workspaces doesn't have nohoist as an option, so I was stuck. I just removed the gts-specific npm scripts from package.json and kept the configs since those were working without issue. I have a top-level lint that is working with gts so I just make sure my CI/CD pipeline uses that.
A workaround:
yarn config set nodeLinker node-modules
or add this to .yarnrc.yml
nodeLinker: node-modules
then run:
yarn
Sourced from https://stackoverflow.com/a/60043794
For me gts 5.2.0 with https://github.com/google/gts/pull/654 fixes the problem. I think this bug can be closed.