smash-middleware-helloworld
raw JSON → 0.0.25 verified Sat Apr 25 auth: no javascript
smash-middleware-helloworld is a middleware for the smash-cli framework, providing a simple hello world example for plugin development. Currently at version 0.0.25, it is part of the smash-cli ecosystem and demonstrates how to create custom middleware. This package is in early development (pre-1.0), with no regular release cadence. It is intended as a learning tool or starting point for building smash-cli middleware. Differentiator: tightly integrated with smash-cli, not suitable for standalone use.
Common errors
error Error: Cannot find module 'smash-middleware-helloworld' ↓
cause Package not installed or not in NODE_PATH.
fix
Run npm install smash-middleware-helloworld
error TypeError: helloWorld is not a function ↓
cause Using named import or destructured require instead of default import.
fix
Use import helloWorld from 'smash-middleware-helloworld'
error Uncaught SyntaxError: The requested module 'smash-middleware-helloworld' is expected to be of type CommonJS but is an ES module ↓
cause Package is ESM-only, but project uses require() or outdated Node.js version.
fix
Use import syntax or set "type": "module" in package.json. Node.js >=12 required.
Warnings
gotcha This middleware requires smash-cli version >= 0.9.0. It will crash if used with older versions. ↓
fix Install smash-cli@>=0.9.0.
breaking Version 0.0.20 changed the export from a factory function to a default export. Direct require or import destructuring will break. ↓
fix Use default import: import helloWorld from 'smash-middleware-helloworld'.
deprecated The 'init' method was deprecated in v0.0.10 and removed in v0.0.15. Use the constructor directly. ↓
fix Replace .init() with new middleware instance.
gotcha The middleware does not export TypeScript type definitions. TypeScript users may see 'could not find a declaration file' errors. ↓
fix Add a dummy declaration file: declare module 'smash-middleware-helloworld';
Install
npm install smash-middleware-helloworld yarn add smash-middleware-helloworld pnpm add smash-middleware-helloworld Imports
- default wrong
const helloWorld = require('smash-middleware-helloworld')correctimport helloWorld from 'smash-middleware-helloworld' - helloWorld
import helloWorld from 'smash-middleware-helloworld' - type definition
import helloWorld from 'smash-middleware-helloworld'; import type { Middleware } from 'smash-cli'
Quickstart
import smash from 'smash-cli';
import helloWorld from 'smash-middleware-helloworld';
const app = smash();
app.use(helloWorld());
app.start();