Redoc: TypeError: createGlobalStyle is not a function when using redoc-cli

Created on 5 Nov 2018  路  9Comments  路  Source: Redocly/redoc

When using the latest redoc-cli (0.6.4), which uses [email protected], I get the following error:

TypeError: createGlobalStyle is not a function

Steps to reproduce

  1. Get the perstore OpenAPI 3 spec: examples/v3.0/petstore.yaml
  2. Run redoc-cli on the petstore:
    shell redoc-cli bundle petstore.yaml -o petstore/

Stack trace

/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:7303
var PSStyling = createGlobalStyle(perfect_scrollbar_templateObject_1 || (perfect_scrollbar_templateObject_1 = external_tslib_["__makeTemplateObject"](["", ""], ["", ""])), perfect_scrollbar_default.a && perfect_scrollbar_default.a.toString());
                ^

TypeError: createGlobalStyle is not a function
    at Module.<anonymous> (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:7303:17)
    at __webpack_require__ (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:36:30)
    at /usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:100:18
    at /usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:103:10
    at webpackUniversalModuleDefinition (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:9:20)
    at Object.<anonymous> (/usr/local/lib/node_modules/redoc-cli/node_modules/redoc/bundles/redoc.lib.js:16:3)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

Most helpful comment

It works

All 9 comments

Adding styled-components 4.0.3 to the dependencies solved it for me.

Don't work for me... I am on windows 10 OS. and using latest code from master branch

  1. npx redoc-cli bundle openapi.yaml
  2. createGlobalStyle is not a function

Does not help.

[email protected]

yarn add [email protected]

npx redoc-cli --version

createGlobalStyle is not a function

I'm not sure that simply adding the peer dependency styled-components is a viable solution. As indicated by other people, this does not seem to solve the issue.

Could you please try [email protected]?

It works

It's seems that the release of [email protected] fixes the problem. However I'm still not sure that adding the peer dependency of styled-components is a viable solution.

@idelsink it is.
redoc is using styled components as a peerDependency and recently the code base was updated to use styled-components@4 which doesn't have injectGlobalStyle anymore.
redoc-cli included redoc as a dependency so has to install valid version of its peer dependencies itself. Before redoc-cli used [email protected] which is incompatible with 4.x

Can confirm: using [email protected] works.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zmes50416 picture zmes50416  路  3Comments

martnst picture martnst  路  3Comments

gavinkalika picture gavinkalika  路  3Comments

dwilding picture dwilding  路  4Comments

JonKohler picture JonKohler  路  3Comments