Total.js framework 4
raw JSON → 0.0.99 verified Fri May 01 auth: no javascript
Total.js framework v4 (v0.0.99) is a Node.js web framework written in pure JavaScript, similar to PHP's Laravel or Python's Django. It supports web, desktop, service, and IoT applications. Known for its high performance and minimalistic design, it includes built-in support for MVC architecture, real-time communication, and a rich set of components. The framework is actively developed with frequent releases on npm. It is fully TypeScript-typed and ships with its own CLI tool. Compared to Express.js, it offers a more opinionated structure and built-in modules for common tasks.
Common errors
error Error: Cannot find module 'total4' ↓
cause Package not installed or installed globally without proper NODE_PATH.
fix
Install locally: npm install total4 --save, then run node with correct path.
error TypeError: F.on is not a function ↓
cause F is not defined because the framework instance wasn't created.
fix
Ensure you have called require('total4') which creates the global F object.
error SyntaxError: Unexpected token import ↓
cause Using ES module import syntax with a CommonJS-only package.
fix
Replace 'import total4 from 'total4'' with 'const total4 = require('total4')'.
error Error: listen EADDRINUSE :::3000 ↓
cause Port 3000 is already in use by another process.
fix
Change the port number or terminate the conflicting process.
Warnings
breaking Total.js v4 is a complete rewrite and not backward compatible with v3. Existing v3 applications must be migrated. ↓
fix Refer to migration guide at https://docs.totaljs.com/total4/migration/.
deprecated The 'F.route()' method from v3 is replaced by 'F.on('request')' in v4. ↓
fix Use F.on('request', handler) instead of F.route().
gotcha ESM imports (import) are not supported; require() must be used. ↓
fix Use CommonJS require() calls instead of import statements.
gotcha The package name is 'total4' not 'total.js' when installing from npm. ↓
fix Run npm install -g total4 (not total.js).
deprecated Built-in CORS support has been removed; you must handle CORS manually. ↓
fix Set CORS headers in your request handler as needed.
Install
npm install total4 yarn add total4 pnpm add total4 Imports
- total4 wrong
import total4 from 'total4'correctconst total4 = require('total4') - Framework wrong
import { Framework } from 'total4'correctconst Framework = require('total4/framework') - U wrong
import U from 'total4'correctconst U = require('total4/utils') - Controller
const Controller = require('total4/controller')
Quickstart
const total4 = require('total4');
// Create a simple web server
F.on('request', function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello from Total.js v4!');
});
F.listen(3000, '0.0.0.0', function() {
console.log('Server running at http://localhost:3000/');
});