Node.js中http-server的使用

使用阿里的npm镜像

国外的npm太慢了。查看一下自己使用的源:

npm config get registry
  • 1

应该显示https://registry.npmjs.org/。这回改成阿里的:

npm config set registry https://registry.npm.taobao.org
  • 1

不过在npm publish时要记得切回去

安装http-server

http-server是一个基于Node.js的简单零配置命令行HTTP服务器. 如果你不想重复的写Node.js的web-server.js, 则可以使用这个. 
安装命令:

npm install http-server -g
  • 1

启动http-server命令就是在cmd下直接输入http-server,之后就可以浏览器访问http://localhost:8080
默认web目录是当前目录,想改变web目录的话,在命令后面加上本地路径,例如:

http-server <path_of_project>
  • 1

查看帮助使用http-server --help,如果想改变端口和地址采用如下方式:

http-server <path> -a 0.0.0.0 -p 8080
  • 1

参数-a是监听地址,而参数-p是修改监听端口。

npm http-server ubuntu的更多相关文章

  1. npm run server报错

    从git上clone的vue项目npm install后npm run server报错 $ npm run dev > lufei@1.0.0 dev E:\pythonProject\luf ...

  2. V Server Ubuntu

    Ubuntu下代理伺服器通常使用squid 安裝 sudo apt-get install squid 修改squid.conf配置 sudo vim /etc/squid/squid.conf 公司 ...

  3. Latest node.js & npm installation on Ubuntu 12.04

    转自:https://rtcamp.com/tutorials/nodejs/node-js-npm-install-ubuntu/ Compiling is way to go for many b ...

  4. 阿里云 Server (Ubuntu 12.04) 配置 FTP

    来自 http://blog.csdn.net/zgrjkflmkyc/article/details/45510345 这个是阿里云的官方用户手册  http://bbs.aliyun.com/re ...

  5. VNC Server (Ubuntu 16.04.3 GNOME)

    1. 安装VNC服务 sudo apt-get install vnc4server -y 2. 启动VNC服务 vncserver :1 3. 此时客户端连上后你会发现灰屏,原因出在~/.vnc/x ...

  6. Ubuntu 下安装 SQL Server 2016初探

    安装步骤参官方 https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-ubuntu 执行命令如下: .Enter supe ...

  7. How to create a PPPoE Server on Ubuntu? (Untested)

    How to create a PPPoE Server on Ubuntu? March 30, 2011 coder_commenter Leave a comment Go to comment ...

  8. Vmware 中安装 Ubuntu Server (或者ubuntu 以文本界面登陆时) 分辨率无法全屏问题

    Vmware 中安装 Ubuntu Server/Ubuntu 分辨率,无法全屏问题 需要更改grub设置 在终端或者文本界面按下列步骤进行设置: 第一步: 输入命令 sudo vim /etc/de ...

  9. SQL Server on Ubuntu——Ubuntu上的SQL Server(全截图)

    本文从零开始一步一步介绍如何在Ubuntu上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一.   创建Ubuntu系统(Create U ...

  10. Ubuntu 安装 SQL Server

    SQL Server现在可以在Linux上运行了!正如微软CEO Satya Nadella说的,"Microsoft Loves Linux",既Windows 10内置的Lin ...

随机推荐

  1. Git:非Fast forward下的合并(--no-ff方式的git merge)

    创建dev分支,并且修改readme.txt的内容,然后提交 使用git merge --no-ff -m "说明内容" 分支名称合并分支 使用git log --graph -- ...

  2. ConcurrentHashMap1.8源码解析

    深入并发包 ConcurrentHashMap 概述 JDK1.8的实现已经摒弃了Segment的概念,而是直接用Node数组+链表+红黑树的数据结构来实现,并发控制使用Synchronized和CA ...

  3. Oracle 如何循环查询结果集,进行新增或修改

    Oracle的PL/SQL中怎样循环查询的结果集,然后根据查询结果进行判断,是新增或修改操作 loop循环例子 for item in (select a,b,c from table_a where ...

  4. vim : Depends: vim-common (= 2:7.4.052-1ubuntu3.1) but 2:7.4.273-2ubuntu4 is to be installed

    sudo apt-get purge vim-commonsudo apt-get updatesudo apt-get upgradesudo apt-get install vim

  5. decltype的参数是左值时,得到一个引用类型

    int* a = new int(10); decltype(*a) 得到的是引用类型:int&

  6. nyoj 0269 VF(dp)

    nyoj 0269 VF 意思大致为从1-10^9数中找到位数和为s的个数 分析:利用动态规划思想,一位一位的考虑,和s的范围为1-81 状态定义:dp[i][j] = 当前所有i位数的和为j的个数 ...

  7. 微信小程序web-view使用测试总结

    1.后台配置业务域名. 2.在开发者工具的web-view组件中绑定业务域名. 3.点击开发者工具的详情按钮,选择调试基础库高版本,如果不设置,有可能绑定的业务域名内容不显示. 4.如果是公众号上的内 ...

  8. JavaScrip(三)JavaScrip变量高级操作(字符串,数组,日期)

    一:字符串 charAt() 返回指定位置的字符 indexof() 返回指定字符串首次出现的位置 replace() 替换指定的字符 concat() 连接两个或多个字符串 substr(start ...

  9. 常见的SQLALCHEMY列类型

    常见的SQLALCHEMY列类型.配置选项和关系选项   类型名称    python类型    描述 Integer int 常规整形,通常为32位 SmallInteger    int 短整形, ...

  10. 向量空间模型(VSM)在文档相似度计算上的简单介绍

    C#实现在: http://blog.csdn.net/Felomeng/archive/2009/03/25/4023990.aspx 向量空间模型(VSM:Vector space model)是 ...