- Overview
- Features
- Teachnologies Used
- Getting Started
- The Yarn PnP Feature
- Common Errors encountered using Yarn Pnp
A React Todo List application where users can create a list of tasks to execute.
- Add Todo: Enter a task to be done.
- Edit Todo: Update a current or previous task.
- Complete Todo: Mark a task completed.
- Undo Todo: Updated a completed task as uncompleted.
- Delete Todo: Delete a completed task.
- React
- Vite
- Chakra UI
- Yarn Berry (PnP and Zero-Install)
- Node.js and yarn are installed
- Clone the repository:
git clone https://github.com/Michle99/R_ALAB_320H_91_Todo_List.git
- Navigate to the project folder:
cd R_ALAB_320H_91_Todo_List
- When the project is cloned, the error below is encountered:
- ERROR:
- Cannot find module '@chakra-ui/icons' or its corresponding type declarations.ts(2307)
- Run the following commands to resolve the errors:
yarn install
Then,
yarn dlx @yarnpkg/sdks vscode
The below pane will appear, click Allow
. The errors should be resolved:
- Start the development server:
yarn run dev
- To use node-modules instead, go to the
.yarnrc.yml
and uncommnet this:
nodeLinker: node-modules
and comment this:
nodeLinker: pnp
Then run the following command:
yarn install
The dependencies are already installed and are present in the repository folder. No need for node_modules in the project folder because of the Yarn PnP feature. To learn more about Yarn PnP, visit here. To initiate Yarn PnP, migration to Yarn PnP.
- Create a vite project with yarn:
yarn create vite my-project-name --template react
- Install dependences:
yarn install
- Add additional dependencies/devDependencies:
yarn add <dependencies-name>
- To use Yarn PnP, use the following commands:
- Start yarn version to berry:
yarn set version berry
This will create a .yarn
& .yarnrc.yml
folder and files respectively.
- Set the
.yarnrc.yml
topnp
, in ordet to use Yarn PnP feature:
yarn config set nodeLinker "pnp"
This will ensure any additional dependencies you download is taken care of by Yarn PnP and installed in the .yarn
folder.
- Run the below command to remove the
node_modules
folder and use Yarn Pnp instead:
yarn install
- Start the development server:
yarn run dev
- Modules resolution for VSCode:
Run the following command, this will create a
.vscode
folder and installsdks
folder in the.yarn
folder.
yarn dlx @yarnpkg/sdks vscode
-
Common Errors encountered using Yarn Pnp:
-
How to configure VSCode to run Yarn 2 (with PnP) powered TypeScript
-
Using
Vitest with Yarn v4.0.2
with PnP,Vite 5.0.0
,Vitest 1.0.4
, andjsdom 23.0.1
or@testing-library/jest-dom": "^6.1.5"
results in the following errors:
Errors encoutered using Vitest and Yarn v4.0.2
-
The Fix for the Vitest/jsdom error testing error I encountered was to use
happy-dom
in place of jest-dom:- Install
happy-dom
:
yarn add -D happy-dom
- Uninstall any and all jest-dom packages.
- For how to do testing with
vitest
andhappy-dom
: How to Unit Test your React TypeScript App With Vitest and React Testing Library.
- Install
-
- Open your browser and visit http://localhost:5173/.