fix: resolve browser compatibility by avoiding Node.js process access in nodeVersionCheck
- Add environment detection using isNode() check - Skip Node.js version validation in browser environments - Return browser-friendly defaults when not in Node.js - Prevents "Cannot read properties of undefined (reading 'isTTY')" error - Ensures external bundlers (Vite, Webpack) work correctly with Brainy 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
a439772aa6
commit
baf80b5f24
1 changed files with 31 additions and 8 deletions
|
|
@ -5,6 +5,8 @@
|
|||
* This prevents V8 HandleScope locking issues in worker threads.
|
||||
*/
|
||||
|
||||
import { isNode } from './environment.js'
|
||||
|
||||
export interface VersionInfo {
|
||||
current: string
|
||||
major: number
|
||||
|
|
@ -16,6 +18,17 @@ export interface VersionInfo {
|
|||
* Check if the current Node.js version is supported
|
||||
*/
|
||||
export function checkNodeVersion(): VersionInfo {
|
||||
// In browser environment, skip version check
|
||||
if (!isNode()) {
|
||||
return {
|
||||
current: 'browser',
|
||||
major: 0,
|
||||
isSupported: true, // Always supported in browser
|
||||
recommendation: 'Browser environment'
|
||||
}
|
||||
}
|
||||
|
||||
// Only access process.version in Node.js environment
|
||||
const nodeVersion = process.version
|
||||
const majorVersion = parseInt(nodeVersion.split('.')[0].substring(1))
|
||||
|
||||
|
|
@ -35,6 +48,11 @@ export function checkNodeVersion(): VersionInfo {
|
|||
export function enforceNodeVersion(): void {
|
||||
const versionInfo = checkNodeVersion()
|
||||
|
||||
// Skip enforcement in browser environment
|
||||
if (!isNode()) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!versionInfo.isSupported) {
|
||||
const errorMessage = [
|
||||
'🚨 BRAINY COMPATIBILITY ERROR',
|
||||
|
|
@ -65,6 +83,11 @@ export function enforceNodeVersion(): void {
|
|||
export function warnNodeVersion(): boolean {
|
||||
const versionInfo = checkNodeVersion()
|
||||
|
||||
// Skip warning in browser environment
|
||||
if (!isNode()) {
|
||||
return true
|
||||
}
|
||||
|
||||
if (!versionInfo.isSupported) {
|
||||
console.warn([
|
||||
'⚠️ BRAINY VERSION WARNING',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue