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

sveltekit: TypeError: Cannot read properties of undefined (reading 'default') #2040

Open
MineYuanlu opened this issue Dec 3, 2024 · 1 comment

Comments

@MineYuanlu
Copy link

protobuf.js version: 7.4.0

using svelte(kit)

pbjs -t static-module -w es6 -l -o ./src/lib/protos/index.js ./protos/*.proto && pbts -o ./src/lib/protos/index.d.ts ./src/lib/protos/index.js
import * as $protobuf from "protobufjs/minimal";

// Common aliases
const $Reader = $protobuf.Reader, $Writer = $protobuf.Writer, $util = $protobuf.util;

// Exported root namespace
const $root = $protobuf.roots["default"] || ($protobuf.roots["default"] = {});

error:

[vite] Error when evaluating SSR module /src/lib/protos/index.js:
|- TypeError: Cannot read properties of undefined (reading 'default')
    at ./src/lib/protos/index.js:7:30
    at async instantiateModule (file://./node_modules/vite/dist/node/chunks/dep-CB_7IfJ-.js:52972:5)
@MineYuanlu
Copy link
Author

add:
"protobufjs-cli": "^1.1.3"

test:

BAD:

import * as $protobuf from "protobufjs/minimal";

GOOD:

import $protobuf from "protobufjs/minimal";

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

1 participant