Continuing with our VS Code Theme, today I've got three items for you (well, one, okay, kind of three, or whatever... )
Node.js Applications with VS Code
Node.js is a platform for building fast and scalable server applications using JavaScript. Node.js is the runtime and NPM is the Package Manager for Node.js modules.
To get started, install Node.js for your platform. The Node Package Manager is included in the Node distribution.
Tip! You can download both the TypeScript and JavaScript versions of the sample application created in this walkthrough from the vscode-samples repository.
Express
Express is a very popular application framework for building and running Node applications. You can scaffold a new Express application using the Express Generator tool, which is typically installed globally on your computer.
...
Great Code Editing Experiences
Close the browser and from a terminal in the
myExpressApp
folder, stop the Node.js server by pressingCTRL+C
. Now launch VS Code....Tip: You can open files or folders directly from the command line. The period '.' refers to the current folder, therefore VS Code will start and open the
myExpressApp
folder.The Node.js and Express documentation does a great job explaining how to build rich applications using the platform and framework. Visual Studio Code will make you more productive developing these types of applications by providing great code editing and navigation experiences.
VS Code uses the TypeScript compiler to drive its JavaScript language service, which means we can take advantage of what the compiler can infer about your code. For example, let's create a simple string variable in
app.js
and send the contents of the string to the console....
Open
app.js
and notice how the warnings no longer appear for__dirname
. This is because VS Code now understands what__dirname
is, based on the metadata from thenode.d.ts
file. Even more exciting, you can get full IntelliSense against the Node framework. For example, you can requirehttp
and get full IntelliSense against thehttp
class as you type in Visual Studio Code.
...
Debugging your Node Application
In order to run and debug your Node application from within VS Code, you need to configure how the application will be started. To do this, click on the Debug icon in the View Bar on the left of Visual Studio Code.
Click on the Configure gear icon at the top of the Debug view to create a default
launch.json
file....
Next Steps
There is much more to explore with Visual Studio Code, please try the following topics:
- Debugging - This is where VS Code really shines
- Editing Evolved - Lint, IntelliSense, Lightbulbs, Peek and Goto Definition and more
- ASP.NET 5 - End to end sample showing off our ASP.NET 5 and .NET 5 support with a sample app
- Tasks - Running tasks with Gulp, Grunt and Jake. Showing Errors and Warnings
So you've seen how quickly you can get Node'js'ing with VS Code.
What? Want some more help? The Microsoft Virtual Academy has got your back...
Using Node.js with Visual Studio Code
Developers, have you heard about Visual Studio Code? Far more than a text editor, it works cross platform, looks great, has a ton of cool features, and is becoming increasingly popular! Check it out, with the always-entertaining experts Stacey Mulcahy and Rami Sayar, and see how to use Visual Studio Code to create sites using Node.js (one of the easiest and fastest ways to develop real-time apps on the web today).
Walk through the tool's features, learn how to customize them, and explore the key commands. See how to create a basic REST API using Node.js with Express, connect your web app to a database, and learn how to debug Node.js apps using Visual Studio Code. Plus, see how to deploy your sites to Microsoft Azure, and create, test, and schedule Azure Web Jobs. Watch helpful demos, and get lots of practical tips on making the most of this exciting tool.
1 | Introduction to Node.js
Explore what Node.js is, its benefits, who is using it, and how to get started. See demos on writing your first Node.js app and on a basic HTTP server. Begin building a basic chat application.
2 | Introduction to Express
See why Express is one of the most popular web frameworks used with Node.js. Get the basics, and watch how to create a basic REST API using Node.js with Express.
3 | Express and Databases
Find out how you can connect your Express web app to a database.
4 | Building a Front End for Your Express Web Apps
See how to build front ends using Jade and Bootstrap for your Express web app.
5 | Debugging and Deploying Node.js
Focus on best practices for debugging node.js apps and deploying Node.js on Azure with Azure Websites and Virtual Machines.
6 | Extending Node.js with Azure Web Jobs
Explore techniques to extend your Node.js application on Azure with Web Jobs. Find out how to deploy, test, and schedule Azure Web Jobs.
Learn
- Get an introduction to Node.js.
- Hear an introduction to Express.
- Explore Express and databases.
- Learn about building a front end for your Express web apps.
- Find out how to extend Node.js with Azure Web Jobs.
- Learn about debugging and deploying Node.js.
Prerequisites
JavaScript experience is required, as is some HTML experience.
Time requirements, modules, assessments and points for this course:
5 hours* 6 modules 6 assessment 102 points
*Excluding labs, knowledge checks and assessments.
Mastering Node.js Modules and Packages with Visual Studio Code
Why choose Node.js for your next project? There are tons of reasons to use this server-side application framework, and two of the biggest are packages and modules, key parts of the Node.js foundation. The Node.js online repository, npm, contains just about any code your project might need, and it's easy to plug in that code and to keep it up-to-date. Plus, you can start giving back to the vibrant node ecosystem by sharing the clever things you have built.
Watch experts Jeremy Foster and Chris Kinsman, as they explore packages and modules and the difference between the two. See Visual Studio Code in action, along with cool demos, including a detailed look at real-world packages and how they are structured. Learn how to create and consume modules, how to bundle them into a package, and how easy it is to publish to npm. If you are already working with node and you're familiar with JavaScript, but you're not sure how packages and modules work behind the scenes, take this opportunity to see how the magic comes together!
(NOTE: If you'd like to review Node.js concepts, take a look at the Microsoft Virtual Academy MEAN Stack Jump Start and the popular course, Using Node.js with Visual Studio Code.)
1 | Introducing Modules
See what modules mean in the world of Node.js and how to obtain modules. Plus, hear a discussion of some of the most commonly used modules.
2 | Module Design Patterns
See how to best create and manage your own modules.
3 | Introducing Packages
See what the differences between modules and packages are. Find out how to obtain packages and how to manage them.
4 | Creating Custom Packages
See how to create your own custom packages.
5 | Publishing Packages
See how to share your packages with the community and with your organization.
6 | Performance and Other Considerations
See how to best structure your packages for performance, and take a look at other best practices.
Learn
- Get an introduction to modules.
- Explore module design patterns.
- Get an introduction to packages.
- Learn how to create custom packages.
- Get the details on publishing packages.
- Explore performance and other considerations.
Prerequisites
Node.js experience would be helpful. JavaScript experience is required.
Time requirements, modules, assessments and points for this course:
4 hours* 6 modules 6 assessment 102 points
*Excluding labs, knowledge checks and assessments.
There, that should get you Node.js'ing!
Follow @CH9
Follow @coding4fun
Follow @gduncan411
