Convert the project folder into a package
By default Visual Studio Code will see any files in the folder as unrelated files. To process your folder as a project entity, Visual Studio Code needs specific information.
To do this, you need to transform your project folder into a package folder. From there you will be able to manage every dependencies in your project. You will be able to download and reference into your project folder any third-party module you need to develop your App.
Go to the View menu of Visual Studio Code and select Command Palette.
Type open and select Open new Command Prompt:
A Command Window opens and the prompt is referencing the project folder:
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.
c:\Users\john\Documents\Visual Studio Code Projects\BlankProject>
Note that you can directly open a Command Prompt from the keyboard shortcut Ctrl+Shift+C.
The type the following command:
> npm init --yes
Have a look to the npm CLI init command : https://docs.npmjs.com/cli/init
What you get from this init command is new file called package.json created at the root of your project folder.
Go back to Visual Studio Code, the new package.json file has been dynamically loaded in the IDE.
Click on the package.json file, Visual Studio will open it in a separate window. It's content should look like :
Package.json content is fully described at https://docs.npmjs.com/files/package.json
There are two entries within the Package.json that you must be aware of:
- The scripts entry;
- The main entry.