Skip to content

jsh: spawn ... ENOENT Running NPM Binary #1519

@shellscape

Description

@shellscape

Describe the bug

Attempting to run an NPM installed package binary results in jsh: spawn email ENOENT. Initially I used pnpm to install things. Locally and in CI systems, pnpm will create a node_modules/.bin/email file that looks like this:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -z "$NODE_PATH" ]; then
  export NODE_PATH="/Users/code/jsx-email/packages/jsx-email/dist/esm/cli/node_modules:/Users/code/jsx-email/packages/jsx-email/dist/esm/node_modules:/Users/code/jsx-email/packages/jsx-email/dist/node_modules:/Users/code/jsx-email/packages/jsx-email/node_modules:/Users/code/jsx-email/packages/node_modules:/Users/code/jsx-email/node_modules:/Users/code/node_modules:/Users/node_modules:/Users/node_modules:/node_modules:/Users/code/jsx-email/node_modules/.pnpm/node_modules"
else
  export NODE_PATH="/Users/code/jsx-email/packages/jsx-email/dist/esm/cli/node_modules:/Users/code/jsx-email/packages/jsx-email/dist/esm/node_modules:/Users/code/jsx-email/packages/jsx-email/dist/node_modules:/Users/code/jsx-email/packages/jsx-email/node_modules:/Users/code/jsx-email/packages/node_modules:/Users/code/jsx-email/node_modules:/Users/code/node_modules:/Users/node_modules:/Users/node_modules:/node_modules:/Users/code/jsx-email/node_modules/.pnpm/node_modules:$NODE_PATH"
fi
if [ -x "$basedir/node" ]; then
  exec "$basedir/node"  --enable-source-maps --no-warnings=ExperimentalWarning "$basedir/../jsx-email/dist/esm/cli/index.mjs" "$@"
else
  exec node  --enable-source-maps --no-warnings=ExperimentalWarning "$basedir/../jsx-email/dist/esm/cli/index.mjs" "$@"
fi

NPM does it a bit different, but you get the idea.

When I ran ❯ cat node_modules/.bin/email I was presented with:

#!/usr/bin/env node --enable-source-maps --no-warnings=ExperimentalWarning
import './main.mjs';

Which is significantly not what it should be. It looks like StackBlitz is having a bad day here.

Link to the blitz that caused the error

https://stackblitz.com/edit/jsx-email-repro

Steps to reproduce

  1. npm i
  2. npm run dev

Expected behavior

I'd expect it to run the NPM script, and the appropriate binary. No clue what it's trying to do presently.

Parity with Local

Screenshots

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions