The ultimate CLI tool for effortlessly running JavaScript, TypeScript, and .jsr
scripts.
⚡ Focus on coding, let JSRUN handle the rest! ⚡
- Automatic Module Management: Automatically installs missing dependencies.
- Version Control: Specify version numbers directly in your imports.
- Caching for Speed: Locally cached modules reduce installation time.
-
Colorful Logging: Clear, colorful logs powered by
chalk
. - Error Handling: Comprehensive error messages for easy troubleshooting.
- Extendable: Customizable and ready for expansion.
- Node.js: Ensure you're using Node.js version 14 or higher. Get Node.js here.
npm install -g jsrun-cli
Run any script supported by JSRUN:
jsrun myscript.jsr
Supported extensions: .jsr
, .js
, .mjs
, .ts
.
import express from "express@4.17.1";
import chalk from "chalk@4.1.2";
console.log(chalk.green("Starting server..."));
const app = express();
app.get("/", (req, res) => res.send("Hello World!"));
app.listen(3000, () => console.log(chalk.blue("Server running on port 3000")));
Run the script:
jsrun server.jsr
jsrun myscript.jsr --port=4000 --env=production
Inside your script:
const args = process.argv.slice(2);
const port =
args.find((arg) => arg.startsWith("--port="))?.split("=")[1] || 3000;
const env =
args.find((arg) => arg.startsWith("--env="))?.split("=")[1] || "development";
console.log(`Running on port ${port} in ${env} mode.`);
jsrun --clean
-
Performance Caching: Caches modules locally in
~/.jsrun/node_modules
to speed up subsequent runs. -
Colorful Logging: Uses
chalk
for colored feedback (Green for success, Yellow for warnings, Red for errors, and Blue for status). - Error Handling: Gives detailed error messages, simplifying debugging and fixing issues.
JSRUN was created to make running JavaScript and TypeScript scripts with modules a breeze, without the hassle of managing node_modules
. Instead of manually installing packages every time, JSRUN handles everything for you. It installs the necessary dependencies automatically, allowing you to create and run executable scripts from anywhere with minimal setup.
No more worrying about how to manage node_modules
just focus on writing and running your scripts, and let JSRUN take care of the rest!
Explore the /examples
directory for use cases and .jsr
script examples.
- Module Not Found: Ensure module names and versions are correct.
-
Permission Denied: Use elevated privileges or adjust the ownership of the
~/.jsrun
folder. - Syntax Errors: Verify that your JavaScript/TypeScript syntax is correct. Use the appropriate Node.js version.
- Network Problems: Check your network connection or try manually installing the module.
-
Why
.jsr
?
.jsr
highlights scripts specifically made forjsrun
. -
Can I use
.js
files?
Yes,.js
files are supported, but.jsr
is recommended for clarity. -
Where are modules installed?
In the cache directory~/.jsrun/node_modules
. -
How do I update
jsrun
?
Runnpm update -g jsrun-cli
.
- Fork the repo
- Create a new branch
- Make your changes
- Push your branch
- Submit a Pull Request
jsrun
is licensed under the MIT License.
Have questions or feedback? Check out our GitHub page.
Pour la documentation en français, consultez ce lien.