Lab 1: Creating a New Project
Objectives
- Create a new React project (app) that uses TypeScript
- Open the new project
- Review the default project structure
Steps
Create a new React project
As part of the course setup, you created a
codedirectory for the course (somewhere on your computer that you would easily remember). If you haven't created acodedirectory yet please do that now.Open a
command prompt(Windows) orterminal(Mac).Change the current directory to your
codedirectory.Run ONE of the following commands:
If you want to use
npmas your package manager.npmnpm create vite@latest projectpilot -- --template react-tsnpm 7+, extra double-dash is needed:
If you want to use
Yarnas your package manager.Yarnyarn create vite projectpilot --template react-tsyarn createis available in Yarn 0.25+
Open the new project
Change the current directory (
cd) to the directory you created in the last step.cd projectpilotInstall dependencies
npm installOpen the
projectpilotdirectory in your editor of choice.If you are using
Visual Studio Codeyou can run the following command in your terminal:code ....
coderefers to Visual Studio Code and.means current directoryMacOS
if
codeis not in yourterminal(Mac)PATHyou will receive the message:command not found: code- in
Visual Studio CodechooseView>Command Palette> Shell Command: Install 'code' command in PATH
Windows
if
codeis not in yourcommand-prompt(Windows)PATHyou will receive the message:command not found: code- You will need to add
codeto the environment variable path manually or rerun the Visual Studio code installer and choose the option to addcodeto the path.
- in
Review the default project structure
Take a few minutes to go over the default project structure. Below are some files to look at:
package.json/index.htmlis the page templatesrc/main.tsxis the JavaScript entry point