Appearance
Web Development
Install NPM and Node.js
On a Home Computer
This installation only needs to be done once.
In order to use Vite, you'll need to install Node.js and NPM. NPM is a package manager for JavaScript. Node.js is a JavaScript runtime environment that allows you to run JavaScript code outside of a browser.
If you don't install Node.js, which also installs NPM, you'll get an error when you try to run npm create vite@latest
. It will say something like npm : The term 'npm' is not recognized
.
Go to https://nodejs.org/en/download/ and download the latest version of Node.js. When you install Node.js, it will also install NPM.
If you still have issues after installation, follow these instructions for Windows.
Create a project using Vite
Create a project from scratch using Vite.
- Open Visual Studio Code or the Command Prompt and go to your main folder, then one with your name.
- Open a new terminal by clicking on the
Terminal
menu button, choosingNew Terminal
, and then enter the following command:
npm create vite@latest
- Enter the name of your project when prompted. Don't use spaces. Example:
tictactoe
ortic-tac-toe
. - Select
Vanilla
, which means basic HTML, CSS, and JavaScript. - Choose
JavaScript
, orTypeScript
if you want. - Open this new project by going to
File
>Open Folder...
and selecting the folder that was just created. - Open the terminal by clicking on
Terminal
in the menu and selectingNew Terminal
. In the terminal typenpm install
, which will install the dependencies for your project. - In your project folder, delete
counter.js
,javascript.svg
, and delete all of the code insidemain.js
. You can also delete the content insidestyle.css
if you want. - Click on
package.json
, then click on theDebug
link that's shown between lines 5 and 6. Choosedev
since we are in the development process. - In the terminal at the bottom, look for the
Local: http://127.0.0.1:xxxx
. Hold down the control button and click on that link. This will open a preview of your app.