Skip to main content

Prerequisites

Before installing P2P File Share, ensure you have the following:

Node.js v22 or higher

This project requires Node.js version 22 or later. Check your version with node --version.
The project has no external npm dependencies - it uses only Node.js built-in modules like net, fs, and crypto.

Installation Steps

1

Verify Node.js version

First, confirm you have Node.js v22 or higher installed:
node --version
You should see output like v22.0.0 or higher. If you need to install or upgrade Node.js, visit nodejs.org.
2

Clone the repository

Clone the P2P File Share repository to your local machine:
git clone <repository-url>
cd p2p-file-share
Replace <repository-url> with the actual repository URL.
3

Verify the installation

Since the project has no external dependencies, you can verify the installation by checking the project structure:
ls -la src/
You should see three JavaScript files:
  • manager.js - File management and hash calculation
  • node.js - P2P networking logic
  • peer.js - Application entry point
4

Test the installation

Verify that the application runs correctly by displaying the usage information:
node src/peer.js
You should see the usage guide:
Uso: node peer.js --port <puerto> --file <rutaArchivo> [--peer <host:puerto>]
Ejemplo (iniciar seed): node peer.js --port 6881 --file "/ruta/al/archivo.ext"
Ejemplo (iniciar peer leecher): node peer.js --port 6882 --file "/ruta/de/salida.ext" --peer 127.0.0.1:6881

Alternative: Using npm Scripts

The package.json file includes convenient npm scripts for common operations:
package.json
{
  "scripts": {
    "start": "node src/peer.js",
    "seed": "node src/peer.js --port 6881 --file ./ruta_al_archivo",
    "leech": "node src/peer.js --port 6882 --file ./ruta_al_archivo --peer <host:puerto>"
  }
}
You can use these scripts as templates:
# View usage information
npm start

# Start a seed node (customize the file path)
npm run seed

# Start a leecher node (customize the file path and peer address)
npm run leech
While these scripts are helpful templates, you’ll typically run the application directly with custom parameters as shown in the Quickstart guide.

Firewall Configuration

Since P2P File Share uses TCP connections, you may need to configure your firewall:
1

Allow incoming TCP connections

Ensure your firewall allows incoming TCP connections on the port you specify with --port. For example, if using port 6881:
Linux (iptables)
sudo iptables -A INPUT -p tcp --dport 6881 -j ACCEPT
macOS (built-in firewall)
# The firewall typically prompts you when the application first runs
# Click "Allow" when prompted
2

Configure router port forwarding (optional)

If you want to share files across the internet (not just on your local network), configure port forwarding on your router to forward the chosen port to your machine’s local IP address.
Exposing P2P File Share to the internet without encryption is not recommended for sensitive data.

System Requirements

RequirementSpecification
Node.jsv22.0.0 or higher
Operating SystemLinux, macOS, or Windows
NetworkTCP connectivity between peers
Disk SpaceSufficient space for files being shared
DependenciesNone (uses Node.js built-in modules only)

Troubleshooting

If you see errors about unsupported features, your Node.js version may be too old. Update to v22 or higher:
# Using nvm (Node Version Manager)
nvm install 22
nvm use 22
If you see EADDRINUSE errors, another application is using the port. Choose a different port number with the --port flag:
node src/peer.js --port 6882 --file "/path/to/file.ext"
If you cannot connect to a peer:
  • Verify the peer is running and listening on the specified port
  • Check firewall settings on both machines
  • Ensure the host and port in --peer are correct
  • Verify network connectivity with ping or telnet

Next Steps

Now that P2P File Share is installed, proceed to the Quickstart guide to share your first file!

Build docs developers (and LLMs) love