storyblok / storyblok-js

JavaScript SDK to connect Storyblok with your favourite framework that we don't have an official SDK for.
http://storyblok.com/
MIT License
39 stars 20 forks source link

Process is not defined #337

Closed rickvandermeij-aanzee closed 1 year ago

rickvandermeij-aanzee commented 1 year ago

Describe the issue you're facing

After updating to 2.2.3 process.env is not defined. Why do we need this in our project. Sure thing you'll need it in cypress, but that should be a different config for your e2e

We had to inject this Polyfill:

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).process = {
    env: { DEBUG: undefined },
};

Reproduction

none

Steps to reproduce

No response

System Info

System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 26.89 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.12.1/bin/yarn
    npm: 8.19.3 - ~/.nvm/versions/node/v18.12.1/bin/npm
    pnpm: 8.3.1 - ~/Library/pnpm/pnpm
  Browsers:
    Chrome: 115.0.5790.114
    Safari: 16.4

Used Package Manager

npm

Error logs (Optional)

No response

Validations

fgiuliani commented 1 year ago

Hi @rickvandermeij-aanzee thanks for submitting this issue.

When are you getting that error?

rickvandermeij-aanzee commented 1 year ago

We upgraded from 2.1.4 to 2.2.3 and using the StoryblokClient.

const storyblokApi = new StoryblokClient(
    apiOptions,
    this.endpoint,
);

should a ternary operator be sufficient?

Screenshot 2023-08-01 at 14 22 11
fgiuliani commented 1 year ago

Hi @rickvandermeij-aanzee we just released a new version of the SDK that includes a fix for this problem.

Can you update to the latest version of the SDK and check if it works for you now?

rickvandermeij-aanzee commented 1 year ago

after updating to 2.2.10 the error is gone without the use of the polyfill