Skip to content

nodejs thinks it is in a browser environment #214

@devdoshi

Description

@devdoshi

I'm not sure if this is something particular to my setup but I was running into:
panicked at 'from_entropy failed: Web API self.crypto is unavailable', /Users/dev/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_core-0.6.2/src/lib.rs:381:13

when using a module created via wasm-pack build --target nodejs ...

Based on my experimentation, it appears

// If `self` is defined then we're in a browser somehow (main window
global/global.self can exist in a nodejs environment so it follows the browser branch instead of the nodejs branch. I haven't set up a minimal reproduction but verified that delete global.self in my nodejs entry point resolved my issue. Thoughts?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions