Usage
run command:
Examples
Execution Options
Compile without executing (useful for checking compilation errors)
Evaluate JavaScript expression instead of reading from file
Evaluate expression and print the result
Source Options
Path to JavaScript or TypeScript file to execute
URL to JavaScript file (HTTPS only)
Performance Flags
Display timing information after executionShows:
- Total compilation + execution time
- Execution time only
Display compiled Wasm binary size
Common Flags
All global flags are supported:-On: Optimization level-d: Debug mode--module: Parse as ES module--parse-types: Enable TypeScript parsing--opt-types: Use type hints for optimization
Output Examples
Script Arguments
Pass arguments to your script after the filename:process.argv:
script.js
Error Handling
Errors are displayed differently based on debug mode:TypeScript Support
Porffor parses TypeScript syntax but does not perform type checking. Type annotations can be used as optimization hints with
--opt-types.Module Support
Parse file as ES module:Remote Execution
Execute JavaScript from HTTPS URLs:Performance Tips
- Use optimization flags:
-O2or-O3for better runtime performance - Enable type hints:
--opt-typeswith TypeScript annotations - Profile first: Use
porf profileto identify bottlenecks - Consider native: For maximum performance, compile to native binary
Limitations
Current limitations when running JavaScript:- Limited async support (
Promiseandawaithave known bugs) - No variables between scopes (except args and globals)
- No
eval()orFunction()(AOT compilation) - Limited standard library support
Related Commands
Profile
Analyze performance bottlenecks
Debug
Interactive debugging
Wasm
Compile to WebAssembly
Native
Compile to native binary