esm.sh provides a fast, global content delivery network publicly which powered by Cloudflare. You may also want to host esm.sh by yourself.
To serve esm.sh, You will need Go 1.18+ to run and compile the server. The server will install Node.js runtime automatically if it's not found on your host machine.
- Linux system
- 4x CPU cores or more
- 8GB RAM or more
- 100GB disk space or more
git clone https://github.com/esm-dev/esm.sh
cd esm.sh
To configure the server, create a config.json
file then pass it to the server bootstrap command. For example:
// config.json
{
"port": 8080,
"tlsPort": 443,
"workDir": "/var/www/esmd",
"storage": "local:/var/www/esmd/storage",
"origin": "https://esm.sh",
"npmRegistry": "https://npmjs.org/registry",
"npmToken": "xxxxxx"
}
You can find all the server options in config.exmaple.jsonc. (Note: the config.example.jsonc
is not a valid JSON file, it's a JSONC file.)
go run main.go --config=config.json --dev
Then you can import React
from http://localhost:8080/react
Please ensure the supervisor has been installed on your host machine.
./scripts/deploy.sh --init
An example Dockerfile is found in the root of this project.