This guide will help you set up your local machine with all the tools you will need (and the webdev industry).
Before you begin, create a folder for this cohort wherever you want to store any GitHub repos that you will be cloning on your device in this cohort. You can name it include, cohort, or literally anything you want to. If you choose to name it "include", do not use a '#' in your folder name, it'll cause a bunch of problems later.
Node.js is a runtime environment that is used to run Javascript code. It comes with the Node Package Manager (npm) that helps us manage the Javascript packages used in our project. To set up node.js:
-
Download the Node.js installer for your OS from https://nodejs.org/en/download/current
-
Run the installer and follow the installation wizard.
-
Once the installation finishes, open a terminal on VSCode and type node --version to verify your node installation. Type npm --v to verify your npm installation.
a. If you get an error saying that node or npm is not recognized as a command, try restarting VSCode to see if the issue fixes itself. (If you had VSCode opened while installing Node, this should fix it.) b. If the problem persists, search for Environment variables in your Start menu. Click on Edit your Environment variables. Click on Environment Variables in the new window that opens up. c. Find the variable Path and click on Edit. d. Check for C:\Program Files\nodejs\ in the list of paths that appear. If it's not there, click on New and add it to the list. e. Restart VSCode and it should ideally work now.
ESLint is an extension that ensures that your code adheres to certain code style. It also auto-formats your code on save in VSCode. To enable it:
-
Go to the Extensions tab on VSCode and install ESLint.
-
Once it is installed, open your Command Palette by pressing Ctrl + SHift + P/Command + Shift + P and search for Preferences: Open Workspace Settings (JSON). Open the file and add this code into the file. This will autoformat your code on save and also configure tab sizes:
{ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, "eslint.validate": ["javascript"], "[javascriptreact]": { "editor.indentSize": 2 }, "[typescriptreact]": { "editor.indentSize": 2 } }
This is a completely optional but super helfpul extension that automatically renames paired HTML tags when you edit them. You can install it on VSCode the same way you installed ESLint.
Set up:
npm install
for package installations. This will install all packages specified in the package.json file.
Run the development server:
npm run dev
Run a linting test:
npm run lint