새로운 반응이 있습니다. 처음에는 create-react-app
을 사용하기 시작했습니다. 파일 이름은 기본적으로 index.js
입니다. 그런 다음 파일 이름을 index.jsx
으로 변경했습니다.반응 파일 이름 지정 규칙 jsx
npm start
을 사용하여 응용 프로그램을 시작하려고하면 아래 오류가 표시됩니다.
> react-scripts start
Could not find a required file.
Name: index.js
Searched in: D:\WorkSpace\React\chat\src
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "D:\\Applns\\nodejs\\node.exe" "D:\\Applns\\nodejs\\node_modules\\
npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'react-scripts start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the chat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
해결 방법 노드에서 jsx 파일을 가져 오려면 어떻게해야합니까?
ReactJS 구성 요소는 .jsx 파일에 있어야합니다. 표준으로? –
그것은 요구 사항은 아니지만 일부 사람들은 그것을 선호합니다. 다른 사람들은'jsx' 변환은 브라우저에서 실행될 수있는 유효한 자바 스크립트로 만들기 위해 파일에서 발생하는 변환 중 하나 일 뿐이므로 다른 이름으로 파일 이름을 지정하는 것은 의미가 없습니다. 필자는 개인적으로 강한 감정을 가지지 않지만 보통'.js' 파일 만 가지고 있으므로 나중에'jsx' 구문을 추가해야 할 필요가 없도록 변경할 필요가 없습니다. –