Visual Studio Code and local web server
It is the start of a New Year and you have decided to try Visual Studio Code, good resolution!
One of the things you will find the most surprising, is that unlike its big brother Visual Studio which has IIS Express, VS Code does not come with a built-in web server…
If you are building a client side SPA, such as an Angular app, it is crucial to develop and test in the context of a web server (http://localhost:xxx/…).
So nothing built-in so far, but no worries, there are at least 1 thousand way to setup a local web server.
I chose to use the following procedure, which is quite simple yet powerful. What works for me might not suit your need, your mileage might vary.
Please note: this is for your Development Environment only, not Production!
The following procedure is valid for MAC or PC.
1. Install Node.js
If not already installed, get it here: https://docs.npmjs.com/getting-started/installing-node
It comes with npm (the package manager for acquiring and managing your development libraries)
2. Create a new folder for your project
Somewhere in your drive, create a new folder for your web app.
3. Add a package.json file to the project folder
Then copy/paste the following text:
{
“name”: “Demo”,
“version”: “1.0.0”,
“description”: “demo project.”,
“scripts”: {
“lite”: “lite-server –port 10001”,
“start”: “npm run lite”
},
“author”: “”,
“license”: “ISC”,
“devDependencies”: {
“lite-server”: “^1.3.1”
}
}
4. Install the web server
In a terminal window (command prompt in Windows) opened on your project folder, run this command:
npm install
This will install lite-server (defined in package.json), a static server that loads index.html in your default browser and auto refreshes it when application files change.
5. Start the local web server!
(Assuming you have an index.html file in your project folder).
In the same terminal window (command prompt in Windows) run this command:
npm start
Wait a second and index.html is loaded and displayed in your default browser served by your local web server!
lite-server is watching your files and refreshes the page as soon as you make changes to any html, js or css files.
And if you have VS Code configured to auto save (menu File / Auto Save), you see changes in the browser as you type!
Notes:
- Do not close the command line prompt until you’re done coding in your app for the day
- It opens on http://localhost:10001 but you can change the port by editing the package.json file.
That’s it. Now before any coding session just type npm start and you are good to go!
Visual Studio Code and local web server的更多相关文章
- Web Servers in Visual Studio for ASP.NET Web Projects
https://msdn.microsoft.com/en-us/library/58wxa9w5(v=vs.120).aspx When you develop web projects in Vi ...
- 对于Web开发最棒的22个Visual Studio Code插件
翻译 原文作者:James Quick 原文地址:https://scotch.io/bar-talk/22-best-visual-studio-code-extensions-for- ...
- Project Perfect让Swift在server端跑起来-Perfect in Visual Studio Code (四)
编者语 : 本系列文章已经被Perfect官方引用了,这样的感觉非常好.感恩!Thx all ! Visual Studio Code是一个轻量级的编辑器,但也功能丰富,通过插件你能够完毕如Cordo ...
- 如何使用Visual Studio Code调试PHP CLI应用和Web应用
在按照Jerry的公众号文章 什么?在SAP中国研究院里还需要会PHP开发? 进行XDebug在本地的配置之后,如果想使用Visual Studio Code而不是Eclipse来调试PHP应用,步骤 ...
- React调试——visual studio code
原文链接:Using React in Visual Studio Code 原文链接:Live edit and debug your React apps directly from VS Cod ...
- Version Controlling with Git in Visual Studio Code and Azure DevOps
Overview Azure DevOps supports two types of version control, Git and Team Foundation Version Control ...
- [一]Cesium利其器——Visual Studio Code
Cesium中文网:http://cesiumcn.org/ | 国内快速访问:http://cesium.coinidea.com/ IDE Web前端刚入门的朋友,常常想选择一个快速.好用.流行( ...
- docker4dotnet #3 在macOS上使用Visual Studio Code和Docker开发asp.net core和mysql应用
.net猿遇到了小鲸鱼,觉得越来越兴奋.本来.net猿只是在透过家里那田子窗看外面的世界,但是看着海峡对岸的苹果园越来越茂盛,实在不想再去做一只宅猿了.于是,.net猿决定搭上小鲸鱼的渡轮到苹果园去看 ...
- ASP.NET Core 中文文档 第二章 指南(1)用 Visual Studio Code 在 macOS 上创建首个 ASP.NET Core 应用程序
原文:Your First ASP.NET Core Application on a Mac Using Visual Studio Code 作者:Daniel Roth.Steve Smith ...
随机推荐
- Python数据结构与算法相关问题与解决技巧
1.如何在列表, 字典, 集合中根据条件筛选数据¶ In [1]: from random import randint In [2]: data = [randint(-10,10) for _ ...
- 红黑树(red-black tree)实现记录
https://github.com/xieqing/red-black-tree A Red-black Tree Implementation In C There are several cho ...
- NIO学习笔记
零.前言 这里整理摘录了我了解NIO的一些笔记. 参考资料: 1.深入浅出NIO之Channel.Buffer 2.深入浅出NIO之Selector实现原理 3.Java NIO vs. IO 一.N ...
- Json常用代码
以下使用的都是fastJson. 先创建Person类,如下: public class Person { @JSONField(name = "AGE") private int ...
- 关于AVL树的思考
AVL树即平衡二叉树,每个结点有一个平衡因子,即左子树高度减去右子树高.每插入一个结点时,从根部开始按二叉排序树的方法,与节点不断比较,按大小向左右子树插入.在与最后的节点比较后插入时,若有兄弟节点, ...
- python note 15 正则表达式
# 正则表达式 只和字符串打交道 # 正则表达式的规则# 规则 字符串 从字符串中找到符合规则的内容 # 字符组 : [] 写在中括号中的内容,都出现在下面的某一个字符的位置上都是符合规则的 # [0 ...
- 20165315 2018-2019-2 《网络对抗技术》Exp0 Kali安装 Week1
20165315 2018-2019-2 <网络对抗技术>Exp0 Kali安装 Week1 一.安装过程 1.基本配置 创建一个新的自定义vm 选择创建自定虚拟机 操作系统选择" ...
- 机器学习(五)--------正则化(Regularization)
过拟合(over-fitting) 欠拟合 正好 过拟合 怎么解决 1.丢弃一些不能帮助我们正确预测的特征.可以是手工选择保留哪些特征,或者使用一 些模型选择的算法来帮忙(例如 PCA) 2.正则化. ...
- VSCode下调试mocha测试用例
之前使用tape做Node.js的单元测试,最方便一条就是使用它就和自己写个控制台应用程序测试一样,控制起来比较灵活,直接用VSCode进行调试也比较方便.然而tape输出中文字符总是乱码,想了很多办 ...
- java之servlet学习基础(二)
上一次写到Servlet的实现方法,主要还是通过继承HttpServlet来实现Servlet.下面主要是回顾一下HttpServletRequest和HttpServletResponse对象中的一 ...