반응형
CLI 환경에서 linear-gradient 라이브러리를 설치하고, web과 android 두 OS를 모두 빌드하는 과정에서 다음과 같은 에러가 발생했다
Module parse failed: Unexpected token (8:36)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.
react-native-linear-gradient는 주로 모바일 환경에서 사용되기에 TypeScript 주석을 Webpack이 처리하지 못해서 발생하는 문제라고 한다.
해결방법은 간단하다
웹 환경에서 react-native-linear-gradient를 사용하지 않도록 설정해주면 된다.
webpack.config.js를 수정해서 웹 환경에서는 react-native-linear-gradient 대신 react-native-web-linear-gradient를 사용하도록 해주자.
resolve: {
extensions: ['.web.js', '.js', '.jsx', '.ts', '.tsx', '.json'],
alias: {
'react-native$': 'react-native-web',
'react-native-linear-gradient': 'react-native-web-linear-gradient', // 웹에서는 react-native-web-linear-gradient 사용
},
},
반응형
'React Native' 카테고리의 다른 글
[React Native] CLI 환경에서 linear-gradient 설치하기 (2) | 2024.09.07 |
---|---|
[React Native] Android OS에서 녹음 기능 구현하기 (Expo) (2) | 2024.08.28 |
[React Native] Animated.View를 사용해서 Pulse 애니메이션 구현하기 (Expo) (0) | 2024.08.22 |