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

process.env is undefined and causes application-crashing error in non-node runtime #92

Closed
AsukaCHikaru opened this issue Jul 16, 2024 · 1 comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler cat: modules aliasing 🔗 Issue related to modules aliasing needs: complete repro 🖥️ Issue need to have complete repro provided

Comments

@AsukaCHikaru
Copy link
Contributor

Environment

Description

In a non-node environment, process.env is undefined thus causing packages/shared/src/findPackageJSON.ts L13 to throw an undefined error which leads to the application crashing.

import { dirname, isAbsolute } from 'path';
import * as process from 'process';

import findUp from 'find-up';

const cache = new Map<string, string | undefined>();

export function findPackageJSON(
  pkgName: string,
  filename: string | null | undefined
) {
  // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
  const isJest = Boolean(process.env.JEST_WORKER_ID);
  ...

Reproducible Demo

https://github.com/AsukaCHikaru/wyw-in-js-vite-env-issue

@AsukaCHikaru AsukaCHikaru added bug report 🦗 Issue is probably a bug, but it needs to be checked needs: complete repro 🖥️ Issue need to have complete repro provided needs: triage 🏷 Issue needs to be checked and prioritized labels Jul 16, 2024
@github-actions github-actions bot added bundler: webpack 📦 Issue is related to webpack bundler cat: modules aliasing 🔗 Issue related to modules aliasing and removed needs: triage 🏷 Issue needs to be checked and prioritized labels Jul 16, 2024
@AsukaCHikaru AsukaCHikaru reopened this Jul 19, 2024
@AsukaCHikaru
Copy link
Contributor Author

solved in #93

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report 🦗 Issue is probably a bug, but it needs to be checked bundler: webpack 📦 Issue is related to webpack bundler cat: modules aliasing 🔗 Issue related to modules aliasing needs: complete repro 🖥️ Issue need to have complete repro provided
Projects
None yet
Development

No branches or pull requests

1 participant