본문 바로가기
Programming

React Native Unable to resolve module index 오류 해결방법

by 혀코 2019. 3. 25.

React Native 로 새로 앱을 빌드하다가 다음과 같은 The development server returned response error code: 500 - Unable to resolve module index 오류를 발견했습니다.

github과 stackoverflow 뒤져보면 package.json에서 버전을 수정하고, node_module 폴더 지운다음에 npm install을 다시 하라는 조언이 많이 있으나 해결할 수 없어서 찾다가 또 찾다가 마침내 찾은 해결방법입니다.

해결 방법은 두가지 입니다. 그 중 첫번째 방법으로 해결할 수 있었습니다.

# 첫번째 방법

\node_modules\react-native\scripts\launchPackager.bat 파일 업데이트

@echo off
title Metro Bundler
call .packager.bat

// delete this line
node "%~dp0..\cli.js" start 

Add this line
node "%~dp0..\cli.js" start --projectRoot ../../../ 

pause
exit


# 두번째 방법

\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js 파일 업데이트

const procConfig = {

    // delete this line    
    cwd: scriptsDir

    // add this line
    cwd: process.cwd()
};


해당 글이 유용하셨다면, 공감 버튼과 구독하기 버튼 클릭 부탁 드립니다.

궁금하신 점이 있으시다면, 아래 댓글로 남겨주세요.

댓글