Creating a basic package

suggest change

The yarn init command will walk you through the creation of a package.json file to configure some information about your package. This is similar to the npm init command in npm.

Create and navigate to a new directory to hold your package, and then run yarn init.

mkdir my-package && cd my-package
yarn init

Answer the questions that follow in the CLI.

question name (my-package): my-package
question version (1.0.0): 
question description: A test package
question entry point (index.js): 
question repository url: 
question author: StackOverflow Documentation
question license (MIT): 
success Saved package.json
✨  Done in 27.31s.

This generates a package.json file similar to the following:

{
  "name": "my-package",
  "version": "1.0.0",
  "description": "A test package",
  "main": "index.js",
  "author": "StackOverflow Documentation",
  "license": "MIT"
}

Now let's add a dependency. The basic syntax is yarn add [package-name].

Run the following to install Express:

yarn add express

This adds a dependencies section to package.json and installs Express.

"dependencies": {
    "express": "^4.15.2"
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents