To set a breakpoint, simply click the area to the left of the line number within the editor as shown in the following figure. Set a breakpoint on line 53, which is the if statement in the route for adding a new item. Once the file picker displays, and select the server.js file. For example, enter Ctrl + P to display the file picker. In addition to being able to run the app and interact with it via the integrated console, you can set breakpoints directly within your code. Enter text in the textbox to add an item to get a feel for how the app works. Open a browser, and navigate to to see the running app. To see this behavior, type process.env in the console: When running the code via F5 (debug mode), Visual Studio Code launches the app and displays the Debug Console window that displays stdout for the app.Īdditionally, the Debug Console is attached to the newly running app so you can type JavaScript expressions, which will be evaluated in the app, and also includes autocompletion. To run the app from Visual Studio Code, press F5. Once you've explored the code, it's time to run the app. You can see which modules support this autocomplete capability by browsing the DefinitelyTyped project, which is the community-driven source of all TypeScript type definitions. This auto-acquisition of typings works for over 2,000 third-party modules, such as React, Underscore, and Express. Visual Studio Code displays the available members of the API available on db.Īutocompletion works because Visual Studio Code uses TypeScript behind the scenes - even for JavaScript - to provide type information that can then be used to inform the completion list as you type. On line 84, enter a new use of the db variable by entering db. Use Visual Studio Code autocompletion with mongoDB To view all references to a variable within the project, right-click the variable, and from the context menu, and select Find All References. This ability to quickly inspect variables, modules, and types within a file is useful during the development of your projects.Ĭlicking your mouse on a variable - such as timestamp - allows you to see all references to that variable within the same file. Hover your mouse over the timestamp on line 11. Select server.js, which is the startup script for the app. js to display all the JavaScript/JSON files in the project along with each file's parent directory In order to orient ourselves within the codebase, let's play around with some examples of some of the navigation capabilities that Visual Studio Code provides.Įnter. Use the following command to install dependencies: npm install Press Ctrl + Shift + ` to display the Visual Studio Code integrated terminal. With this Node.js project, you must first ensure that all of the project's dependencies are installed from npm. Select (or create) the local directory into which you want to clone the project. When prompted for the Repository URL, enter, then press Enter. To get started, clone the sample project using the following steps:Īt the command palette prompt, enter gitcl, select the Git: Clone command, and press Enter. Choose to create an Azure Cosmos DB resource for a MongoDB database.Install the Docker and Remote - Containers extension to get a multi-container configure with one of the containers running a local mongoDB database. Choose to run this local project in a multi-container configuration where one of the containers is a mongoDB database.If you don't have a mongoDB database available, you can: The examples in this article use a mongoDB database connection string. Visual Studio Code integrates with git to provide Source Control management in the Side Bar.Īdd environment variables needed. Learn the steps to developer and debug your JavaScript Node.js project with Visual Studio.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |