react native too many open files

agnusdei·2024년 9월 7일
  • metro.config.js
const { withNxMetro } = require('@nx/expo');
const { getDefaultConfig } = require('@expo/metro-config');
const { mergeConfig } = require('metro-config');
const path = require('path');

const projectRoot = __dirname;
const workspaceRoot = path.resolve(projectRoot, '../../..');

const defaultConfig = getDefaultConfig(projectRoot);
const { assetExts, sourceExts } = defaultConfig.resolver;

/**
 * Metro 설정
 * https://reactnative.dev/docs/metro
 *
 * @type {import('metro-config').MetroConfig}
 */
const customConfig = {
  transformer: {
    babelTransformerPath: require.resolve('react-native-svg-transformer'),
  },
  resolver: {
    assetExts: assetExts.filter((ext) => ext !== 'svg'),
    sourceExts: [...sourceExts, 'cjs', 'mjs', 'svg'],
    useWatchman: true,
    blockList: [
      new RegExp(`${path.resolve(workspaceRoot, 'node_modules/react-native')}/.*`),
      new RegExp(`${path.resolve(workspaceRoot, 'node_modules/@babel')}/.*`),
      // 여기에 제외할 다른 디렉토리나 파일을 추가하세요
    ],
  },
  watchFolders: [
    path.resolve(projectRoot, 'src'),
    path.resolve(projectRoot, 'assets'),
    workspaceRoot,
    // 필요한 경우 여기에 다른 폴더를 추가하세요
  ],
  watchman: {
    followSymlinks: true,
  },
  maxWorkers: 2,
  resetCache: true,
};

module.exports = withNxMetro(mergeConfig(defaultConfig, customConfig), {
  // 디버깅 정보를 보려면 이것을 true로 변경하세요.
  // 모듈 해결에 문제가 있을 때 유용합니다
  debug: true,
  // 'ts', 'tsx', 'js', 'jsx', 'json' 외에 임포트에 사용되는 모든 파일 확장자
  extensions: ['js', 'jsx', 'ts', 'tsx', 'json', 'cjs', 'mjs', 'svg'],
  // Nx 기본값(작업 공간 라이브러리 및 node_modules) 외에 감시할 폴더를 지정합니다
  watchFolders: [
    path.resolve(projectRoot, 'src'),
    path.resolve(projectRoot, 'assets'),
    workspaceRoot,
    // 필요한 경우 여기에 다른 폴더를 추가하세요
  ],
}).then((config) => {
  config.watchFolders = config.watchFolders.map((folder) => path.resolve(folder));
  return config;
});
  • blockList 추가

ulimit 4096
brew update
brew upgrade
brew cleanup
brew uninstall watchman
brew install watchman
brew upgrade watchman
watchman watch-del-all
watchman shutdown-server
watchman
  • watchman의 설정은 메모리에 저장되며, 프로세스가 종료되면 설정이 초기화됩니다. 즉, watchman을 재시작하면 이전에 설정한 감시 목록이나 상태는 사라지게 됩니다.
profile
DevSecOps Pentest🚩

0개의 댓글