Skip to content

Commit 4948828

Browse files
authored
fix(cli): add globalThis.crypto polyfill for Node.js 18 (#771)
1 parent 774bbbb commit 4948828

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/nuxi/src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import nodeCrypto from 'node:crypto'
12
import { resolve } from 'node:path'
23
import process from 'node:process'
34

@@ -11,6 +12,11 @@ import { setupGlobalConsole } from './utils/console'
1112
import { checkEngines } from './utils/engines'
1213
import { logger } from './utils/logger'
1314

15+
// globalThis.crypto support for Node.js 18
16+
if (!globalThis.crypto) {
17+
globalThis.crypto = nodeCrypto as unknown as Crypto
18+
}
19+
1420
export const main = defineCommand({
1521
meta: {
1622
name: name.endsWith('nightly') ? name : 'nuxi',

0 commit comments

Comments
 (0)