-
-
Notifications
You must be signed in to change notification settings - Fork 26
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
[prettier-plugin-sh]: TypeError [Error]: Cannot set property crypto of #<Object> which has only a getter #216
Comments
Occurs due to import { randomFillSync } from 'node:crypto';
import _fs from 'node:fs';
import { performance } from 'node:perf_hooks';
globalThis.fs = _fs;
globalThis.crypto = {
// @ts-expect-error
getRandomValues: randomFillSync,
};
// @ts-expect-error
globalThis.performance = performance;
//# sourceMappingURL=shim.js.map Specifically: globalThis.crypto = {
// @ts-expect-error
getRandomValues: randomFillSync,
}; Perhaps a workaround would be: if (!globalThis.crypto) {
globalThis.crypto = {
// @ts-expect-error
getRandomValues: randomFillSync,
};
} |
Would you like to raise a PR to
https://github.com/un-ts/sh-syntax/blob/5ead2a9c2304a0f5c9e1a0cfc1e4b6db69762d2b/src/shim.ts#L6 |
And also, please close issues on mvdan/sh and gopherjs, they're not related. |
Sure! Sorry about that. Resolved in un-ts/sh-syntax#52 |
Setting
NODE_OPTIONS="--experimental-global-webcrypto"
causes a crash:The
--experimental-global-webcrypto
enables the Web Crypto API from the browser in NodeJS as the global crypto property.While I’ve disabled experimental NODE_OPTIONS while running prettier, this issue will likely occur in NodeJS v18.x, which become the LTS version in October 2022.
The text was updated successfully, but these errors were encountered: