MOCKSTACKS
EN
Questions And Answers

More Tutorials









NodeJS Yarn Package Manager

Creating a basic package


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 will generate 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 lets try adding a dependency. The basic syntax for this is yarn add [package-name]

Run the following to install ExpressJS

yarn add express

This will add a dependencies section to your package.json, and add ExpressJS

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


Conclusion

In this page (written and validated by ) you learned about NodeJS Yarn Package Manager . What's Next? If you are interested in completing NodeJS tutorial, your next topic will be learning about: NodeJS Localization.



Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue: mockstacks@gmail.com.


Share On:


Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using Mockstacks.com, you agree to have read and accepted our terms of use, cookies and privacy policy.