Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gyandeeps opened this issue Jun 1, 2017 · 32 comments
Closed

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

gyandeeps opened this issue Jun 1, 2017 · 32 comments

Comments

@gyandeeps
Copy link

gyandeeps commented Jun 1, 2017

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 😄 .
@leo
Copy link
Contributor

leo commented Jun 1, 2017

@igorklopov

@igorklopov
Copy link
Contributor

igorklopov commented Jun 1, 2017

@gyandeeps why do you use node_modules/.bin/now instead of node_modules/.bin/now.cmd? Do you use Cygwin? Windows prepends extensions like .exe and .cmd once it is going to execute a program. So now files are not executed. Their .exe or .cmd counterparts are executed.

If you delete now.cmd and eslint.cmd from .bin do they stop working? This is a question to get more info about your env.

@gyandeeps
Copy link
Author

I am not doing anything special, that how npm works on windows.
example if i want to run eslint i do ./node_modules/.bin/eslint.

I deleted eslint.cmd and it still works.

@igorklopov
Copy link
Contributor

Well, does node_modules/.bin/now.cmd work?

@gyandeeps
Copy link
Author

So whenever you execute a package through npm like

{
     "lint": "eslint"
}

npm run lint: will hit the eslint.cmd to execute that. same goes for things which are installed globally.

Initially I installed now globally and ran the command now. that also when i got the same error. I am using git bash on windows. Not sure if that makes a difference or not. But again just changing that file content made everything work regardless on how you call the command.

@etoxin
Copy link

etoxin commented Jun 16, 2017

I am also getting this issue:

OS: Windows 8.1
Node: Using nodist (multiple versions)
now: latest
CLI: hyper w/ cygwin

@sylvainlap
Copy link

Same issue here.

@albertosantini
Copy link

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.

@albertosantini
Copy link

Any news? 7.2.2 doesn't fix it.

Below the script expected for $USERPROFILE/AppData/Roaming/npm/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/node_modules/now/download/dist/now" "$@"
  ret=$?
else
  node  "$basedir/node_modules/now/download/dist/now" "$@"
  ret=$?
fi
exit $ret

You can notice there is something wrong in the installation because now script doesn't have executable permissions (in git bash environment).

@igorklopov
Copy link
Contributor

npm/cmd-shim#25

igorklopov added a commit that referenced this issue Jul 10, 2017
@leo
Copy link
Contributor

leo commented Jul 11, 2017

Fixed in #713

@leo leo closed this as completed Jul 11, 2017
leo pushed a commit that referenced this issue Jul 11, 2017
* add support of nodejs 0.10

* handle 'incorrect header check' error from gunzip

* fix progress bar

* use async-retry restart after 'incorrect header check'

* fix for #613
@subodhpareek18
Copy link

The issue still exists on git bash on windows

@albertosantini
Copy link

albertosantini commented Jul 18, 2017

@zusamann I don't think the patch was included in the latest version 7.2.4.

Or do you mean you tested the master and it doesn't work?

@subodhpareek18
Copy link

Oh sorry for the confusion, I simply used the latest release and did not build from master.

@albertosantini
Copy link

7.3.0 works fine. Thanks.

@leo
Copy link
Contributor

leo commented Jul 31, 2017

👌

@dbarrett24
Copy link

Getting this issue today on version 8.1.0, Windows 10, using gitbash.

Anybody have a solution? Keep getting No such file or directory.

@gyandeeps
Copy link
Author

same here... I had to use powershell to make it work...

@yunyu
Copy link

yunyu commented Sep 9, 2017

Same on 8.2.1 with git bash...

@albertosantini
Copy link

Sigh. 8.2.1 doesn't work.

See also #729.

+ now@8.2.1
updated 1 package in 24.149s
16:02:38 [/c/My/Dev]
$ now -v
/c/Users/xobeci/AppData/Roaming/npm/now: line 1: /node_modules/now/download/dist/now: No such file or directory
16:02:57 [/c/My/Dev]
$

Anyway using now.cmd is ok.

@leo
Copy link
Contributor

leo commented Sep 9, 2017

We haven't tackled Git for Windows yet, but I suppose we should do that, now that so many people are interested in it. @igorklopov?

@leo leo reopened this Sep 9, 2017
@njc12345
Copy link

njc12345 commented Sep 21, 2017

now not working on Windows 10 : Git Bash.

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

Error: /c/Users//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 $?

@flieks
Copy link

flieks commented Sep 21, 2017

i'm getting the same

@borekb
Copy link

borekb commented Sep 26, 2017

I'm no expert but shouldn't now be a shell script? For example, compare cat now and cat tsc:

$ cat /c/Users/Borek/AppData/Roaming/npm/now
"$basedir/node_modules/now/download/dist/now"   "$@"
exit $?
$ cat /c/Users/Borek/AppData/Roaming/npm/tsc
#!/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/node_modules/typescript/bin/tsc" "$@"
  ret=$?
else
  node  "$basedir/node_modules/typescript/bin/tsc" "$@"
  ret=$?
fi
exit $ret

I think that's what I've seen in most bootstrap scripts.

@varna
Copy link

varna commented Oct 11, 2017

Windows 10, Git Bash
$ now.cmd works

@albertosantini
Copy link

Sigh again.
Apart a few single releases, like 7.3.0, in 9.0.0-canary.9 there is the issue.

Any news?

@Qix- Qix- added the triage label Nov 10, 2017
@leo
Copy link
Contributor

leo commented Nov 13, 2017

https://twitter.com/zeithq/status/930180257864437760

@leo leo closed this as completed Nov 13, 2017
@albertosantini
Copy link

@leo are you sure?

Using git bash 2.15.0.windows.1, node 9.1.0 and npm 5.5.1, now is installed locally (and not globally).

$ npm ls now
tobedefined@1.0.0 C:\My\Dev\zzz\tobedefined
`-- now@8.5.1

$ node_modules/.bin/now ls
node_modules/.bin/now: line 1: /../now/download/dist/now: No such file or directory
  • node_modules/.bin/now.cmd ls works.
  • If you use now inside a npm script, it works: "deploy": "now deploy --public && now alias".
  • The installation is fixed (Fails install on Windows #729).

@leo leo reopened this Nov 14, 2017
@leo leo closed this as completed Nov 14, 2017
@leo
Copy link
Contributor

leo commented Nov 14, 2017

@albertosantini What command did you use to install it?

@albertosantini
Copy link

npm install now

@leo
Copy link
Contributor

leo commented Nov 14, 2017

It should be npm install -g now. The -g flag is required for installing packages globally.

@albertosantini
Copy link

Well... I want to install locally (per project) the package and there should not be any diff in terms of "executable".

At least, I didn't notice any difference using other tools, if they are installed globally or locally.

I don't (cannot) think now doesn't support this use case. :)

TooTallNate pushed a commit that referenced this issue Aug 23, 2019
* add bench

* remove yarn.lock

* refactor and extract launcher logic

* add entrypoints to bench

* Update packages/now-node/src/launcher.ts

Co-Authored-By: Steven <steven@ceriously.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests