Skip to content

Missing shebang in bin file causes execution failure on Linux/WSL #8

@Tsunami433

Description

@Tsunami433

Description

The package's bin file (build/index.js) is missing the Node.js shebang line (#!/usr/bin/env node), which causes the package to fail when executed via npx on Linux or WSL environments.

Steps to Reproduce

  1. Run on Linux or WSL:

    npx -y @illuminaresolutions/n8n-mcp-server
  2. Observe the error:

    /home/user/.npm/_npx/.../node_modules/.bin/n8n-mcp-server: 1: import: not found
    /home/user/.npm/_npx/.../node_modules/.bin/n8n-mcp-server: 2: import: not found
    ...
    

Expected Behavior

The server should start successfully with the message:

N8N MCP Server running on stdio

Actual Behavior

The shell tries to interpret the JavaScript file directly instead of running it with Node.js, resulting in syntax errors.

Root Cause

The build/index.js file is missing the shebang line at the top:

#!/usr/bin/env node

Suggested Fix

Add the shebang to src/index.ts or modify the build script in package.json to prepend it:

"scripts": {
  "build": "tsc && echo '#!/usr/bin/env node' | cat - build/index.js > temp && mv temp build/index.js && chmod +x build/index.js"
}

Or simply add it to the source file src/index.ts:

#!/usr/bin/env node
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
// ... rest of the code

Workaround

Manually add the shebang after installation:

sed -i '1i#!/usr/bin/env node' ~/.npm/_npx/*/node_modules/.bin/n8n-mcp-server

Environment

  • OS: Linux / WSL2
  • Node.js: v18+
  • Package version: 1.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions