launch-editor-middleware
raw JSON → 2.13.2 verified Sat Apr 25 auth: no javascript
Express middleware that opens files in the user's default editor when requested via a URL. Version 2.13.2 is current; it is part of the launch-editor ecosystem by Evan You. It relies on launch-editor to resolve the editor and is typically used in development tooling like Vue CLI or Vite to open source files directly from the browser console. No active development fork, but stable and widely used. Differentiator: simple integration with Express, zero-config editor detection.
Common errors
error Cannot find module 'launch-editor-middleware' ↓
cause Package not installed.
fix
Run
npm install launch-editor-middleware --save-dev. error TypeError: launchEditorMiddleware is not a function ↓
cause Missing function call parentheses.
fix
Change
app.use('/__open-in-editor', launchEditorMiddleware) to app.use('/__open-in-editor', launchEditorMiddleware()). Warnings
breaking In version 2.x, the middleware signature changed from `app.use('/__open-in-editor', launchEditorMiddleware)` to `app.use('/__open-in-editor', launchEditorMiddleware())`. ↓
fix Call the function: `app.use('/__open-in-editor', launchEditorMiddleware())`.
gotcha The middleware only works in development environments; production builds should not include it. ↓
fix Conditionally apply the middleware only when `NODE_ENV` is not `'production'`.
deprecated The `default` import is the same as the named import; both are valid. ↓
fix Use either import style consistently.
Install
npm install launch-editor-middleware yarn add launch-editor-middleware pnpm add launch-editor-middleware Imports
- default wrong
const launchEditorMiddleware = require('launch-editor-middleware')correctimport launchEditorMiddleware from 'launch-editor-middleware' - launchEditorMiddleware wrong
const launchEditorMiddleware = require('launch-editor-middleware').defaultcorrectconst { launchEditorMiddleware } = require('launch-editor-middleware')
Quickstart
import express from 'express';
import launchEditorMiddleware from 'launch-editor-middleware';
const app = express();
app.use('/__open-in-editor', launchEditorMiddleware());
app.listen(3000, () => console.log('Server running on port 3000'));