Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pin styled-components version until ReferenceError: window is not defined fixed #1563

Closed
pierot opened this issue Mar 31, 2021 · 7 comments
Closed

Comments

@pierot
Copy link

pierot commented Mar 31, 2021

See: styled-components/styled-components#3444
If it's possible to pin the version number of styled-components in the mean time.

@pierot pierot changed the title Pin styled-components version until error fixed Pin styled-components version until ReferenceError: window is not defined fixed Mar 31, 2021
@RomanHotsiy
Copy link
Member

@pierot I'm not sure why you see the error because redoc-cli uses a npm-shrinkwrap file which should prevent this issue.

How do you run the redoc-cli?

I just tried npx redoc-cli@0.10.4 bundle https://redocly.github.io/redoc/openapi.yaml -o petstore.html and it worked on my machine.

Maybe I have some cache though.

@flixx
Copy link

flixx commented Mar 31, 2021

We've got the same error since today in our Pipelines...

------                                                                          
 > [apidoc 6/6] RUN redoc-cli bundle     --options.pathInMiddlePanel     -o /data/build/index.html     -t custom_template.hbs     /data/openapi/published-specs.yaml:                                                                           
#34 1.571 Prerendering docs                                                     
#34 3.167 ReferenceError: window is not defined
#34 3.167     at k (/usr/local/share/.config/yarn/global/node_modules/styled-components/dist/styled-components.cjs.js:1:7161)
#34 3.167     at e._emitSheetCSS (/usr/local/share/.config/yarn/global/node_modules/styled-components/dist/styled-components.cjs.js:1:22249)
#34 3.167     at e.getStyleTags (/usr/local/share/.config/yarn/global/node_modules/styled-components/dist/styled-components.cjs.js:1:22428)
#34 3.167     at /usr/local/share/.config/yarn/global/node_modules/redoc-cli/index.js:216:25
#34 3.167     at Generator.next (<anonymous>)
#34 3.167     at fulfilled (/usr/local/share/.config/yarn/global/node_modules/redoc-cli/index.js:6:58)
------

@RomanHotsiy
Copy link
Member

How is redoc-cli installed in the pipeline? using npm or maybe yarn? Also what version do you run in pipelines?

Sorry for maybe dumb questions, I'm just trying to understand how this happens provided we have npm-shrinkwrap in place.

Thanks.

@flixx
Copy link

flixx commented Mar 31, 2021

@RomanHotsiy Not a dumb question. Here you go:

FROM alpine:latest as apidoc
RUN apk --no-cache add git yarn && \
    yarn global add redoc-cli
COPY ./apidocs/openapi/ /data/openapi/
RUN mkdir -p /data/build

RUN redoc-cli bundle \
    --options.pathInMiddlePanel \
    -o /data/build/index.html \
    /data/openapi/published-specs.yaml

@RomanHotsiy
Copy link
Member

As I expected it is most likely caused by yarn not respecting npm-shrinkwrap.json.

Could you switch to npm and let me know if that works:

FROM alpine:latest as apidoc
RUN npm install -g redoc-cli
COPY ./apidocs/openapi/ /data/openapi/
RUN mkdir -p /data/build

RUN redoc-cli bundle \
    --options.pathInMiddlePanel \
    -o /data/build/index.html \
    /data/openapi/published-specs.yaml

@flixx
Copy link

flixx commented Mar 31, 2021

@RomanHotsiy Indeed it does fix it! But you forgot one line.
Here for reference the working Dockerfile:

FROM alpine:latest as apidoc
RUN apk --no-cache add npm && \
    npm install -g redoc-cli
COPY ./apidocs/openapi/ /data/openapi/
RUN mkdir -p /data/build

RUN redoc-cli bundle \
    --options.pathInMiddlePanel \
    -o /data/build/index.html \
    /data/openapi/published-specs.yaml

Thanks a lot!

@RomanHotsiy
Copy link
Member

This has been fixed in upstream: styled-components/styled-components#3446 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants