vercel: Windows: Doesn't work because of .bin executable issue

Environment

  • OS: Windows 7/10
  • Node: 8
  • now: latest
  • CLI: git for windows (2.13)

Steps

Install

npm install now

Run

./node_modules/.bin/now -v

Error

./node_modules/.bin/now: line 1: /../now/download/dist/now: No such file or directory

Findings

Current: node_modules/.bin/now

"$basedir/../now/download/dist/now"   "$@"
exit $?

Expected: node_modules/.bin/now

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

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

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../now/download/dist/now" "$@"
  ret=$?
else 
  node  "$basedir/../now/download/dist/now" "$@"
  ret=$?
fi
exit $ret

Note: By making this change it fixes the issue

ESLint example

I used ESLint generated code and replaced the file paths.

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

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

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../eslint/bin/eslint.js" "$@"
  ret=$?
else 
  node  "$basedir/../eslint/bin/eslint.js" "$@"
  ret=$?
fi
exit $ret

Notes/Questions

  • Really not sure why this is happening, maybe how its packaged?
  • We at ESLint doesn’t do anything special and all this is generated by npm install process.
  • Sorry if this is duplicate. I did try searching 😄 .

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 32 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Windows 10, Git Bash $ now.cmd works

now not working on Windows 10 : Git Bash.

Node Version: v8.5.0 NPM Version: v5.4.2

Error: /c/Users/<userName>/AppData/Roaming/npm/now: line 1: /node_modules/now/download/dist/now: No such file or directory

Content of /c/Users/Nikunj/AppData/Roaming/npm/now

“$basedir/node_modules/now/download/dist/now” “$@” exit $?

Using git bash (on Windows 10) and installing now globally I get the error:

$ now -v
[...cut $USERPROFILE path...]/AppData/Roaming/npm/now: line 1: /node_modules/now/download/dist/now: No such file or directory

$ now.cmd -v
7.1.1

https://docs.npmjs.com/files/package.json#bin

Please make sure that your file(s) referenced in bin starts with #!/usr/bin/env node, otherwise the scripts are started without the node executable!

For npm to create the shim right, as suggested by @gyandeeps, the script defined in the bin property of package.json must have the shebang line #!/usr/bin/env node.