Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Can't run Spectacle in a monorepo managed by Yarn workspaces #204

@thekevinbrown

Description

@thekevinbrown

We're trying to use spectacle in a monorepo structured like this:

project:
  packages:
    api-1
    api-1-docs
    api-2
    api-2-docs

We're using Yarn workspaces, and because api-1-docs and api-2-docs share the Spectacle dependencies, they get hoisted up to the node_modules folder in project instead of landing in individual node_modules folders inside of api-1-docs and api-2-docs.

This is all fine until I try to run spectacle swagger.json. Then I get:

$ spectacle swagger.json

>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-contrib-cssmin" not found. Is it installed?
>> Local Npm module "grunt-contrib-watch" not found. Is it installed?
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-contrib-connect" not found. Is it installed?
>> Local Npm module "grunt-compile-handlebars" not found. Is it installed?
>> Local Npm module "grunt-prettify" not found. Is it installed?
>> Local Npm module "grunt-sass" not found. Is it installed?
>> Local Npm module "grunt-embed" not found. Is it installed?
Task error: [Error: Task "sass:foundation_scss" not found.
<stack trace>

It looks like this is because grunt's loadNpmTasks doesn't resolve modules as Node would. When I check in the parent node_modules folder all of those modules are there.

My workaround for the moment is:

pushd ../.. && spectacle packages/api-1-docs/swagger.json -t packages/api-1-docs/public && popd

But that's really messy. Is there any way to get Spectacle to resolve the grunt tasks the same way Node would so I can change the command back to spectacle swagger.json?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions