Skip to content

[bug]: algoliasearch doesn't compile with Node 20 #1594

Open

Description

@IchordeDionysos

Description

When compiling we get the following error:


node_modules/@algolia/client-common/dist/common.d.ts:43:20 - error TS2304: Cannot find name 'Storage'.

43     localStorage?: Storage | undefined;
                      ~~~~~~~

Steps to reproduce:

  • Run mkdir algolia-test && cd algolia-test
  • Run npx gts init
  • When you read package.json does not exist. Generate: type y
  • Run npm install algoliasearch
  • Run npm install @types/node@20
  • Add import {algoliasearch} from 'algoliasearch'; to the top of the index.ts
  • Run npm run compile

Client

All

Version

5.35.0

Relevant log output

npm run compile           

> compile
> tsc

node_modules/@algolia/client-common/dist/common.d.ts:43:20 - error TS2304: Cannot find name 'Storage'.

43     localStorage?: Storage | undefined;
                      ~~~~~~~


Found 1 error in node_modules/@algolia/client-common/dist/common.d.ts:43

Activity

  1. Haroenv commented on Aug 8, 2025

    @Haroenv
    Contributor

    This isn't enough information, you have not provided what typescript settings you're using which cause this error. Please create a full reproduction first.

  2. shortcuts commented on Aug 8, 2025

    @shortcuts
    Member

    it seems like it resolves to the browser build for some reason so should indeed be related to the tsconfig

  3. IchordeDionysos commented on Aug 26, 2025

    @IchordeDionysos
    Author

    @Haroenv if you follow the exact steps I provided you can see the exact typescript settings I am using!

  4. IchordeDionysos commented on Aug 26, 2025

    @IchordeDionysos
    Author

    tsconfig.json

    {
      "extends": "./node_modules/gts/tsconfig-google.json",
      "compilerOptions": {
        "rootDir": ".",
        "outDir": "build"
      },
      "include": [
        "src/**/*.ts",
        "test/**/*.ts"
      ]
    }

    tsconfig-google.json

    {
      "compilerOptions": {
        "allowUnreachableCode": false,
        "allowUnusedLabels": false,
        "composite": true,
        "forceConsistentCasingInFileNames": true,
        "lib": ["ES2023"],
        "module": "commonjs",
        "noEmitOnError": true,
        "noFallthroughCasesInSwitch": true,
        "noImplicitReturns": true,
        "pretty": true,
        "sourceMap": true,
        "stripInternal": true,
        "strict": true,
        "target": "ES2022"
      },
      "exclude": ["node_modules"]
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions