跟我一起从零开始一个预告片电影网站(一)
大家好呀,很久没有见啦,我的博客也写得少啦我也不够努力啦
一寸光阴一寸金,我们一起加油,不断进步呀
第一步
mkdir douban-trailer-imooc
cd douban-trailer-imooc
第二步跟我一起在git中输入
npm init
记得比较重要的地方是
entry point: (index.js) server/index.js
第三步
mkdir server
cd server
touch index.js
//server/index.js
const Koa = require('koa')
const app = new Koa()
app.use(async(ctx,next)=>{
ctx.body = '电影首页'
})
app.listen(4455)
接下来安装koa
npm install koa@latest -S
本来可以使用node server/index.js运行项目 但是是很长的一串,我们可以在package.json中修改命令
//package.json
{
"name": "douban-trailer-imooc",
"version": "1.0.0",
"description": "",
"main": "server/inder.js",
"scripts": {
"start": "node server/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"movie",
"trailer"
],
"author": "dimple",
"license": "ISC",
"dependencies": {
"koa": "^2.11.0"
}
}
运行
npm start

作者:jser_dimple
-------------------------------------------
个性签名:一个人在年轻的时候浪费自己的才华与天赋是一件非常可惜的事情
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!
万水千山总是情,打赏5毛买辣条行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!
微信

支付宝


浙公网安备 33010602011771号