npm init
package.json 생성된다.
{
"name": "react-nodebird-front",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
npm i next@9
설치 중 에러 발생
npm ERR! A complete log of this run can be found in:
해결방법
아래 명령어를 차례대로 입력해준다.
(이렇게해도 안될경우, node를 삭제한 후, 다시 받아야합니다.)
npm cache clean --force
npm install --cache
next9 설치됐습니다.
npm i react react-dom
pages 폴더 안에 index.js 을 만들어준다.
index.js
import React from 'react';
const Home = () => {
return(
<div>hellow next</div>
)
}
export default Home;
next에서는 pages폴더를 폴더명을 pasge로 꼭 만들어주야 한다.
next가 pages폴더 안에 있는 파일들을 인식해서, 개별적인 페이지로 만들어준다. pages폴더 안에 들어 있어야만, 코드스플리팅이 된다.
아래 텍스트를 입력해, 서버를 실행해준다.
npm run dev