Skip to content
← Back to Community
Packages
Profile icon
[deleted]

What are packages, and how do you use them?

Answered by SixBeeps [earned 5 cycles]
View Answer
Comments
hotnewtop
Profile icon
SixBeeps

Packages are big collections of code that other people have written that you can use in your own projects. There are a wide variety of packages, and they all have many different functionalities.

On Repl.it, you can go to the Packages tab:
image
and search for packages there (if that language has package support on here). Should be intuitive enough: search for a package, click on it, and install by clicking the (+) button.

Python uses a package manager called 'pip', which pulls from PyPI (Python Package Index)
You can import packages installed through pip by using import:

import calendar import time import mycoolpackage

Node and its subvariants use npm (Node Package Manager)
You use the require() function to import packages:

fs = require('fs'); http = require('http');

Ruby uses RubyGems, Lua uses LuaRocks, .NET uses NuGet, the list goes on and on.

Profile icon
Arlan-Muratbeko

@SixBeeps I dont haveeee thhiiiiiisssssssv
image

Profile icon
Arlan-Muratbeko

@Arlan-Muratbeko HELP ME!!!

Profile icon
SixBeeps

@Arlan-Muratbeko What's the language of your Repl?

Profile icon
[deleted]

@Coder100 @JavaMaster1 @SixBeeps

So why do I see people using it in their projects? Like a lot of them have the poetry thing. What does that do?

Profile icon
Whacko

@poetaetoes I don't know what that package is, but people use them in their projects because it helps them make things that can't be made without them. Although packages may be tricky, they are super helpful in some projects.

Profile icon
SixBeeps

@poetaetoes Poetry help keep track of other packages (like which ones are used and which ones to include in builds). Not all Python projects need it, but Repl.it has it in every Python Repl.
Also, after a while, complex code gets too complicated and using pre-existing code help speed up the process by quite a bit. I couldn't imagine having to code my own JSON interpreter just for a small project.

Profile icon
Coder100

Before we talk about packages, we first talk about files.

Imagine you had a big project in one file. There would be a lot of components you could export into a different file, so you can just use them as necessary:

import myMethods myMethods.doThis()
# myMethods.py def doThis(): print("idk")

that allows you to reuse code, on a bigger level! Now packages are just like that, except they are published to a global repository so anyone can use them, like Flask or express!!

Profile icon
Whacko

Packages are like extensions you import with a specific code so you can have different codes that the package does. Like, when you add a code that imports color, you get color. Here is for node.js:

const whatYouAreImporting = require('package')

And pyhton:

import package

And npm:

$npm install package

See? Cool, right?