Install Tools#
This is the first step before you can create a project.
You will need to install a development environment that supports compiling, testing and running your application. You will need the following:
- Git client
- node.js
- Vite
- Vitest
Git client#
Any recent version of Git can be installed, and it should be preinstalled on macOS and Linux systems. You can also download and install a Windows version from the main Git site.
node.js#
- Install it from node.js. Check the box for extra tools to be installed, including choclatey.
- Verify it worked using: node -v (if the version number is returned, then your environment is running as it should be).
- Determine its location using: where node (the path should be returned).
- Confirm that it is working using: node (prompt then changes to >), then console.log(“Hello from Node!”) (Hello from Node! should be printed).
- After the node.js install, from the command line in Git Bash, (to get latest npm verion) run npm install -g npm@12.0.2 (version number will change in time, as suggested by the product itself).
Vite#
The instructions below are summarized from the above, and capture what I did for my own Windows setup.
- From Git Bash prompt, run: npm init @vitejs/app, and follow the prompts. (e.g. I created a project called sandbox with Vanilla settings, so replace this name below with your project name).
- Once in Vite, use h for help.
- cd sandbox
- npm install
After this, to launch Vite:
- cd sandbox
- npm run dev (then you can view your site at: http://localhost:5173/)
Vitest#
The instructions below are summarized from the above, and capture what I did for my own Windows setup.
- Navigate to your local Vite folder.
- npm install -D vitest
- Add to .gitignore: .vitest/
- Add to package.json
- There should already be a section called scripts
- Add this line at the end of that section, also adding a comma to separate the previous last item from this new last item: “test”: “vitest”
- Download sum.js to your local Vite folder.
- Download sum.test.js to your local Vite folder.
- Download square-root.test.js to your local Vite folder.
- Run all your tests: npm test
- The above will run all tests (.test.js) in your project.
- You can filter to a subset of the tests by specifying a name after “test”.
Last Word#