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

Running any subcommand throws SyntaxError on Windows #37

Closed
andreeib opened this issue Apr 27, 2018 · 9 comments
Closed

Running any subcommand throws SyntaxError on Windows #37

andreeib opened this issue Apr 27, 2018 · 9 comments

Comments

@andreeib
Copy link

Running any subcommand throws a SyntaxError on Windows:

$ meta git clone git@github.com:mateodelnorte/meta.git
C:\Users\Andreeib\AppData\Roaming\npm\node_modules\meta\node_modules\.bin\meta-git.cmd:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
                                                              ^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:607:28)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
$ node -v
v8.11.1

$ npm -v
5.8.0

If I replace this line:
https://github.com/mateodelnorte/commander.js/blob/245bc4c84ba72d447ab30ec3e2a4456e34052b59/index.js#L576
with:
proc = spawn(bin, args, { stdio: 'inherit', customFds: [0, 1, 2] });
it works.

In windows the npm bin is a batch file and not JavaScript.

meta-git-clone.cmd
@IF EXIST "%~dp0\node.exe" (
  "%~dp0\node.exe"  "%~dp0\..\meta-git\bin\meta-git-clone" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\..\meta-git\bin\meta-git-clone" %*
)
@kendlee
Copy link

kendlee commented Apr 30, 2018

I've also experienced a similar issue as OP, when I cloned the meta repo:
And I'm unable to use the meta clone command, as well as the other commands.

Using windows 7, with the node version:

$ node -v
v8.11.1

$ npm -v
5.6.0

$ meta git clone git@github.com:mateodelnorte/meta.git
D:\userdata\kelee\nvm\v8.11.1\node_modules\meta\node_modules\.bin\meta-git.cmd:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
                                                              ^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
    at bootstrap_node.js:609:3

@skynetigor
Copy link

I have the same issue. I tried that has written by andreeib and it works fine for me.
I'm using last available version of NodeJS (10.0.0).

@mateodelnorte
Copy link
Owner

mateodelnorte commented Apr 30, 2018 via email

@jsuhard
Copy link

jsuhard commented Apr 30, 2018

Hi,

the proposed fix is not sufficient : commands are well executed but result does not show up in the prompt

I make a PR to fix this issue : mateodelnorte/commander.js#1

@jsuhard
Copy link

jsuhard commented May 2, 2018

Hi @mateodelnorte,

as tj/commander.js#604 seems to hang, do you mind to release now a new NPM package with this fix ?

Thanks,

@mateodelnorte
Copy link
Owner

mateodelnorte commented May 2, 2018 via email

@jsuhard
Copy link

jsuhard commented May 3, 2018

Hi @mateodelnorte ,

as commander dependency is from your github (who already contains the fix), new install from scratch is working fine on Windows :-)

@kendlee
Copy link

kendlee commented May 7, 2018

Hi @mateodelnorte,

I confirm what @jsuhard said: performing a fresh install of meta globally already fixes the issue on Windows! 👍

@mateodelnorte
Copy link
Owner

Great. Thanks 😁

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

5 participants