Yarn Workflow and creating a new Project
In this tutorial, we will look at the yarn workflow as well as how to create a new project.
Yarn workflow
When you introduce a package manager into your project, it introduces a new workflow around dependencies. Yarn will attempt to stay out of your way and make every step of the workflow simple enough for you to understand.
These are the few things you need to know about the basic workflow:
- Creating a new project
- Adding/updating/removing dependencies
- Installing/reinstalling your dependencies
- Working with version control (e.g. git)
- Continuous Integration
Creating a new project
Whether you are starting a completely new project or you have an existing repository, the addition of Yarn works exactly the same way.
All you need to do is to open the terminal in the directory that you want to add Yarn ( which is usually the root of your project) and then run the following command:
```yarn init```
Running the command above, will open up an interactive form for creating a new yarn project with the following questions:
```name (your-project):
version (1.0.0):
description:
entry point (index.js):
git repository:
author:
license (MIT):```
You can either type answers for each of these or you can select the default by hitting enter/return key.
package.json
Once you are done with answering the questions from the interactive form, you should have a package.json file in your directory that is similar to this:
```{
"name": "my-new-project",
"version": "1.0.0",
"description": "My New Project description.",
"main": "index.js",
"repository": {
"url": "https://example.com/your-username/my-new-project",
"type": "git"
},
"author": "Your Name <[email protected]>",
"license": "MIT"
}```
Whenever you run yarn init, the package.json file is the end product. There is nothing happening in the background, you can easily edit this files as much as you want.
Your package.json file will be used to store information about your project. This information includes the name of your project, the project maintainers, the repository of the project, but most importantly it contains information on the dependencies that needs to be installed for the project.
Previous:
Troubleshooting Yarn Plug'n'Play (PnP) Issues.
Next:
Installing Dependencies and working with version control.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://w3resource.com/yarn/the-yarn-workflow-and-creating-a-new-project.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics