• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

예제 속 디버깅 오류

20.10.25 23:40 작성 조회수 803

0

+ 안드로이드 애뮬레이터를 실행하고 초기 화면도 오류가 뜨면서 실행되지 않습니다.

강의 속 타이핑한 코드를 그대로 옮겨 적었는데 아래와 같은 디버깅 오류가 뜹니다.

타이핑한 코드

/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 *
 * @format
 * @flow
 */

import React, { Component } from 'react';
import { ViewTextStyleSheet } from 'react-native';

class App extends Component{

  render() {
    return(
      <View style={Styles.background}>
        <Text> Hello world</Text>
      </View>

    )
  }
}

const styles = StyleSheet.create({
  background: {
    flex : 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center'
  }
})

export default App;

디버깅 콘솔

C:\Program Files\nodejs\node.exe .\App.js

Debugger attached.

(node:2188) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

(Use `node --trace-warnings ...` to show where the warning was created)

Waiting for the debugger to disconnect...

c:\Users\onesm\Desktop\AppDevel\react_01\App.js:9

import React, { Component } from 'react';

^^^^^^

SyntaxError: Cannot use import statement outside a module

    at wrapSafe (node:internal/modules/cjs/loader:999:16)

    at Module._compile (node:internal/modules/cjs/loader:1047:27)

    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:10)

    at Module.load (node:internal/modules/cjs/loader:948:32)

    at Function.Module._load (node:internal/modules/cjs/loader:789:14)

    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:72:12)

    at node:internal/main/run_main_module:17:47

Process exited with code 1

(node:2188) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.

(Use `node --trace-warnings ...` to show where the warning was created)

null: Uncaught c:\Users\onesm\Desktop\AppDevel\react_01\App.js:9

import React, { Component } from 'react';

^^^^^^

SyntaxError: Cannot use import statement outside a module

어떤 부분을 수정헤야 하나요?

답변 1

답변을 작성해보세요.

0

onesmind97,<o:p></o:p>

안녕하세요. 지식공유자 Wintho입니다.<o:p></o:p>

<o:p> </o:p>

문의 주신 내용에 답변 드립니다.<o:p></o:p>

<o:p> </o:p>

이전 질문주신 내용과 연관이 있어보입니다.<o:p></o:p>

‘Debugger attached.’ <o:p></o:p>

‘Waiting for the debugger to disconnect…’ 라는 로그가 뜨는 걸로 봐서,<o:p></o:p>

Debugger 붙었다가 disconnect되지 않는 오류로 생각됩니다.<o:p></o:p>

<o:p> </o:p>

만일, 코드가 굉장히 단조롭고 간단했다면<o:p></o:p>

Debugger 붙지 않았을 경우는 실행이 되었을 것이고요,<o:p></o:p>

Debugger 붙은 순간에 빌드가 되었다면 실행이 되었을 겁니다.<o:p></o:p>

<o:p> </o:p>

Visual Studio Code 다시 설치해보시고(1.42버전),<o:p></o:p>

Debugging 하는 과정은 생략해보시기 바랍니다.<o:p></o:p>

<o:p> </o:p>

감사합니다.<o:p></o:p>