1
package.json

2
2.1 package.json
{
"scripts": {
"start": "http-server -a 0.0.0.0 -p 8000"
}
}
2.2命令:npm install http-server

这时候的 package.json
{
"scripts": {
"start": "http-server -a 0.0.0.0 -p 8000"
},
"dependencies": {
"http-server": "^0.12.0"
}
}
2.3 创建主页
<html>
<head>
<title>test</title>
</head>
<body>
hello word
<body>
</html>
文件结构

2.4 运行效果
执行命令:npm start

浏览器输入:http://127.0.0.1:8000/

本文详细介绍如何通过npm安装http-server模块,并将其配置到package.json中,实现一键启动本地HTTP服务器。文章还展示了如何创建一个简单的HTML主页,并通过运行npm start命令在浏览器中预览。
3503

被折叠的 条评论
为什么被折叠?



