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

Get 'command not found' error for some command (like npm) #8

Open
akfish opened this issue Jun 27, 2014 · 6 comments
Open

Get 'command not found' error for some command (like npm) #8

akfish opened this issue Jun 27, 2014 · 6 comments
Assignees
Labels

Comments

@akfish
Copy link
Contributor

akfish commented Jun 27, 2014

Environment

  • Windows 7 x64
  • Node v0.10.21

Steps

  1. Run web-terminal in cmd.exe
  2. Open localhost:8088/terminal/ in browser
  3. Run commands in web terminal, some of them return error message [command name]: command not found.

Commands that run perfectly in a native terminal but won't work with web terminal:

  • npm
  • coffee
  • gulp

One thing they have in common is that they are all commands of globally installed node modules.

@akfish
Copy link
Contributor Author

akfish commented Jun 28, 2014

I did some more testing and found the cause.
In Windows, node creates a *.cmd file in %USERPROFILE%\AppData\Roaming\npm for each global module command. While the native cmd.exe doesn't need the file extension to find the command, the child_proccess.spawn does.

So to get those commands listed above working, just add the file extensions:

  • npm.cmd
  • coffee.cmd
  • gulp.cmd

Though it's nice to fix this or at least document it.

@rabchev rabchev added the bug label Jun 28, 2014
@rabchev rabchev self-assigned this Jun 28, 2014
@rabchev
Copy link
Owner

rabchev commented Jun 28, 2014

I will fix it next week, I don't have Windows machine at home.

@rabchev
Copy link
Owner

rabchev commented Jul 4, 2014

I'm not sure what's the best way to resolve this issue. At first I thought I would just add .cmd at the end if the command isn't found, but that is really lame. Probing seems like a bad idea in the first place and there might be other extensions like .bat that wouldn't work either.

There is one workaround though, you can start web-terminal with -h (--shell) option, like this:

  $ web-terminal -h cmd

Do you have any better ideas?

@akfish
Copy link
Contributor Author

akfish commented Jul 4, 2014

I would try to emulate what the cmd does:

  1. Load all folder paths specified by PATH environment variable
  2. Search executable by file name in those folders
  3. Spawn with full path
    Note that there could be some security issues to expose a system like that. It would be nice to have the option to disable this feature.
    An alternative as opposed to use PATH is to give users the ability to config search paths or command white-list/alias-list in config files.

@akfish
Copy link
Contributor Author

akfish commented Jul 9, 2014

@rabchev Check out this package:
https://www.npmjs.org/package/which
Found it when working on another project. It should do the trick.

@michaelpalumbo
Copy link

michaelpalumbo commented Jul 15, 2018

Environment
Windows 10 x64
Node 10.x

Following up on this thread, some commands are not recognized, such as 'npm', 'dir', 'ls', 'start'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants