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
ESLintdoesn’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
- fix for #613 — committed to vercel/vercel by igorklopov 7 years ago
- Support for Node.js 0.10 and Git for Windows (#713) * add support of nodejs 0.10 * handle 'incorrect header check' error from gunzip * fix progress bar * use async-retry restart after 'incor... — committed to vercel/vercel by igorklopov 7 years ago
- [now-node] Benchmark helpers (#613) * add bench * remove yarn.lock * refactor and extract launcher logic * add entrypoints to bench * Update packages/now-node/src/launcher.ts Co-Author... — committed to vercel/vercel by lucleray 5 years ago
Windows 10, Git Bash
$ now.cmdworksnow 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 $?
https://twitter.com/zeithq/status/930180257864437760
https://github.com/npm/cmd-shim/pull/25
Using git bash (on Windows 10) and installing
nowglobally I get the error:https://docs.npmjs.com/files/package.json#bin
For npm to create the shim right, as suggested by @gyandeeps, the script defined in the
binproperty ofpackage.jsonmust have the shebang line#!/usr/bin/env node.