本前端修改自 Next.js 小作业
按照小作业手册的指导,安装完成node.js与pnpm。
举例来说,WSL2可以这样操作:
mkdir ~/workspace && cd ~/workspace
wget https://nodejs.org/dist/v22.14.0/node-v22.14.0-linux-x64.tar.xz
tar -xf node-v22.14.0-linux-x64.tar.xz
cd node-v22.14.0-linux-x64/bin
pwd请将这个输出的路径添加到环境变量中。为了方便,你可以在 ~/.bashrc 最后加上这句话:
export PATH=~/workspace/node-v22.14.0-linux-x64/bin:$PATH随后回到你的终端,运行:
source ~/.bashrc以重载配置。
至此我们安装好了 node.js ,可以终端输入指令 node -v 确认。
接下来,我们启用包管理器,下载项目,安装依赖:
corepack enable # 启用包管理器的管理器 corepack
git clone <OUR_PROJECT>
cd <PATH_TO_OUR_PROJECT>
pnpm install # 安装项目依赖直接在项目文件夹里运行:
pnpm dev接下来你可以在 http://localhost:3000/ 看到前端页面
This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev
# or
pnpm devOpen http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.
API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts.
The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.