简体   繁体   English

节点:找不到命令-在wsl bash

[英]node: command not found - in wsl bash

I install docker on my windows 10. after that I get a message that I need to download and install wsl2 .我在我的 windows 10 上安装了 docker。之后我收到一条消息,我需要下载并安装wsl2

Now, when I run bash command I get wsl bash .现在,当我运行bash命令时,我得到 wsl bash

When I try to run node I get an error ( node.exe is installed in my windows10 ):当我尝试运行node时出现错误( node.exe 安装在我的 windows10 中):

DESKTOP-BVRDS:/tmp/docker-desktop-root/mnt/host/c/Users/myuser# node
bash: node: command not found

when I run echo $PATH I get output of:当我运行echo $PATH时,我得到 output :

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

and not the windows path's.而不是 windows 路径。 (where the node and other software installed). (安装节点和其他软件的位置)。

How to solve this error?如何解决这个错误? maybe change the default bash?也许更改默认的 bash? to git bash?到 git bash? (which I don't know how) (我不知道怎么做)

In Cmder, open settings: Win + Alt + P在Cmder中,打开设置: Win + Alt + P

  1. Under Startup > Tasks, add a task called {bash} with the following settings:在 Startup > Tasks 下,添加一个名为 {bash} 的任务,其设置如下:

    Task parameters (set icon):任务参数(设置图标):

      For Cmder icon:  /icon "%CMDER_ROOT%\cmder.exe"
      For Git icon: /icon "C:\Program Files (x86)\Git\etc\git.ico"

Commands (open Git's bash shell):命令(打开 Git 的 bash shell):

      "C:\Program Files (x86)\Git\bin\sh.exe" -l -new_console:d:%USERPROFILE%
  1. Under Startup, set startup options to Specified name task --> {bash}在 Startup 下,将启动选项设置为Specified name task --> {bash}

Please check below a couple of articles and should solve an issue.请检查以下几篇文章,应该可以解决问题。

https://gist.github.com/nickautomatic/02ccb76292f7f8d9767e https://gingter.org/2016/11/16/running-windows-10-ubuntu-bash-in-cmder/ https://gist.github.com/nickautomatic/02ccb76292f7f8d9767e https://gingter.org/2016/11/16/running-windows-10-ubuntu-bash-in-cmder/

Please try below:请尝试以下:

  1. Open a regular command prompt ( win+r then cmd )打开常规命令提示符( win+r然后cmd
  2. Right-click the title bar and select Properties右键单击标题栏和 select Properties
  3. Deselect "Use legacy console (requires restart)"取消选择“使用旧版控制台(需要重新启动)”

Now it should work either by launching the standalone app, or typing bash into a regular cmd window after restarting Command Prompt.现在它应该可以通过启动独立应用程序来工作,或者在重新启动命令提示符后将bash输入到常规cmd window 中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM