安装淘宝镜像 npm install -g cnpm --registry=https://registry.npm.taobao.org 然后再 cnpm install -g http-server 即可 如果出现报错cnpm : 无法加载文件 C:\Users\hp\AppData\Roaming\npm\cnpm.ps1,因为在此系统上禁止运行脚本。 解决方式: 1、在系统中搜索框 输入 Windos PowerShell 2、点击“管理员...
- `npm`: Node 包管理器(Node Package Manager),用于安装、管理和发布 Node.js 模块。 - `install`: npm 的命令之一,用于安装模块。 - `-g`: 全局安装(global),将模块安装到全局环境,使其可以在任何地方使用。 - `http-server`: http-server 是一个简单的零配置命令行 HTTP 服务器,用于快速共享静态资源。
在macOS 或 Linux 上,你可以打开终端(Terminal)。 输入安装命令: 在命令行终端中输入以下命令来全局安装 http-server: bash npm install -g http-server 这里-g 参数表示全局安装,这样你就可以在任何目录下使用 http-server 命令了。如果你只想在当前项目中安装 http-server,可以省略 -g 参数: bash npm insta...
如果你需要一个替代的http服务器包,我推荐使用Express.js。Express.js是一个流行的Node.js Web应用程序框架,它提供了简单而灵活的方式来构建Web应用程序。你可以使用以下命令安装Express.js: npm install express 你可以在这里找到更多关于Express.js的信息和文档:https://expressjs.com/ 希望以上信息对你有帮助!如果...
首先,需要全局安装http-server模块:npm install -g http-server。然后,在项目的根目录下运行以下命令启动本地服务器:http-server。默认情况下,服务器将在localhost的8080端口上运行,您可以在浏览器中通过访问http://localhost:8080来访问您的静态文件。 使用express模块:express是Node.js中使用最广泛的Web应用程序框架...
1、全局安装 http-server npm install http-server -g 2、到某已目录下安装 npm install http-server 3.init npm npm init yes 在package.js中加入 "scripts": { "start": "http-server -a 127.0.0.1 -p 7070" } 4.执行 npm start 服务器开启 http://www.cnblogs...
npm install http-server Usage: http-server [path] [options] [path]defaults to./publicif the folder exists, and./otherwise. Now you can visithttp://localhost:8080to view your server Note:Caching is on by default. Add-c-1as an option to disable caching. ...
npm install -g httpserver Usage runhttpserveron the command line to fire up a server on0.0.0.0port8080. $ httpserver { "lo0": "127.0.0.1", "en1": "10.0.1.204" } server started: http://0.0.0.0:8080 See the page athttp://localhost:8080. ...
npm install http-server -g 加参数-g就可以在任何目录启动: http-server . --port 80 自己写: varhttp = require('http'); http.createServer(function(request, response) {//发送 HTTP 头部 // HTTP 状态值: 200 : OK // 内容类型: text/plainresponse.writeHead(200, {'Content-Type': 'text/plai...
npm -g installnpm@2.9.1(2.9.1是版本号) Npmconfig set registryhttp://…设置镜像 npm update -g npm 3.安装完成了,开始使用http-server。 最简单的使用方法,直接使用http-server,默认使用localhost和8080端口。在浏览器中输入网址:localhost:8080可访问呢 ...