不支持 Node.js Cygwin

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10043177/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 15:27:40  来源:igfitidea点击:

Node.js Cygwin not supported

node.jscygwininstall

提问by Mj1992

I am trying to install node.js. I followed this tutorialand i am stuck in the middle.

我正在尝试安装 node.js。我跟着本教程,我被困在中间。

When I write ./configurein my cygwin terminal it says "cygwin not supported". Please help me out Thanks in advance.

当我./configure在 cygwin 终端中写入时,它说“不支持 cygwin”。请帮助我提前致谢。

回答by troy

Node in my experience runs fine in cygwin, what Node usually has EINVAL errors in seems to be MINTTY which is a terminal emulation 'skin' that is default to cygwin. I still am not sure why these EINVAL errors happen 100% but the following are the steps and tricks I use to get node working.

根据我的经验,节点在 cygwin 中运行良好,节点通常有 EINVAL 错误的似乎是 MINTTY,这是默认为 cygwin 的终端仿真“皮肤”。我仍然不确定为什么这些 EINVAL 错误会 100% 发生,但以下是我用来使节点工作的步骤和技巧。

In my /cygwin/home/{username}/.bashrc I add node to path so cygwin can find it

在我的 /cygwin/home/{username}/.bashrc 中,我将节点添加到路径中,以便 cygwin 可以找到它

export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"

If you run a 32 bit version of node:

如果您运行 32 位版本的节点:

export PATH=$PATH:"/cygdrive/c/Program Files (x86)/nodejs/"

Then to make npm run without windows to linux issues I launch cygwin in admin mode then run:

然后为了让 npm 在没有 windows 到 linux 问题的情况下运行,我在管理员模式下启动 cygwin 然后运行:

dos2unix '/cygdrive/c/Program Files/nodejs/npm'

At this point running files and most npm packages will run in MINTTY just fine, although every once and awhile you will run into EINVAL issues with certain npm packages as karma. Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:

在这一点上,运行文件和大多数 npm 包将在 MINTTY 中运行得很好,尽管偶尔你会遇到某些 npm 包作为业力的 EINVAL 问题。此外,您将无法直接在 MINTTY 中运行解释器,无论何时我想做这些事情,我都会运行:

cygstart /bin/bash

This will open a native cygwin bash.exe window, from here you run the interpreter or an any troubling package command that results in a EINVAL. It slightly sucks you have to do this but I rarely use this day to day, and I love MINTTY too much to not use it.

这将打开一个本机 cygwin bash.exe 窗口,从这里您可以运行解释器或任何导致 EINVAL 的令人不安的包命令。你必须这样做有点糟糕,但我每天很少使用它,而且我太喜欢 MINTTY 以至于不使用它。

Also note that you can run any one line node code in MINTTY by just running something like:

另请注意,您只需运行以下内容即可在 MINTTY 中运行任何一行节点代码:

node -e "console.log('hello node')"

回答by Kat

As a simpler derivative of troy's answer for those just looking to install NPM packages:

对于那些只想安装 NPM 包的人来说,作为 troy 答案的一个更简单的衍生物:

  1. Install Node.jswith the Windows installer package.
  2. Add it to the PATH with export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"(obviously replacing the path to Node.js's installation directory with where you installed it).
  3. There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm. This is a bug for all of Windows and not just Cygwin. At some point of the future, you won't have to do this anymore, but the command shouldn't have any negative side effects.
  4. Test it. Eg, npm install pretty-diff -g.
  5. In order to be able to run the newly installed software, you'll need to add the install locations to your PATH. You can find these with npm bin -gand npm bin(the -gflag is the "global" installation location).
  1. 使用 Windows 安装程序包安装Node.js。
  2. 将其添加到 PATH 中export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"(显然是将 Node.js 安装目录的路径替换为您安装它的位置)。
  3. Windows 版本中有一个当前的错误,可以通过运行mkdir -p ~/AppData/Roaming/npm. 这是所有 Windows 的错误,而不仅仅是 Cygwin。在未来的某个时候,您将不再需要这样做,但该命令不应有任何负面影响。
  4. 测试一下。例如,npm install pretty-diff -g
  5. 为了能够运行新安装的软件,您需要将安装位置添加到 PATH。您可以使用npm bin -g和找到它们npm bin-g标志是“全局”安装位置)。

Not really anything special that you have to do to get it to run in Cygwin (although I can't say if everything works).

为了让它在 Cygwin 中运行,你不需要做任何特别的事情(虽然我不能说一切是否正常)。

回答by Petter Thowsen

Use Console2, it allows you to run create tabs of CLI shells. It seems running cygwin inside console2 allows me to use node REPL just fine. I have no idea why :P

使用 Console2,它允许您运行 CLI shell 的创建选项卡。似乎在 console2 中运行 cygwin 允许我很好地使用节点 REPL。我不知道为什么:P

Follow this guide to add cygwin to console2:
http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html

按照本指南将 cygwin 添加到 console2:http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html

回答by u3758939

For windows, Just run bash.exe in cmd, so that you could have a bash work around with cmd console directly, which could support ALL NODE WORKING PERFECTLY.

对于 Windows,只需在 cmd 中运行 bash.exe,这样您就可以直接使用 cmd 控制台进行 bash 工作,这可以完美支持所有节点工作。

C:\Users\郷>bash

郷@CHIGIX ~
$ node
>

回答by AnrDaemon

I'm using this wrapper in /usr/local/bin/node(note no extension!)

我正在使用这个包装器/usr/local/bin/node(注意没有扩展名!)

#!/bin/sh

_cmd="$(cygpath -lw -- "" )"
shift

"/proc/cygdrive/C/Program Files/nodejs/node.exe" "$_cmd" "$@"

This is far from perfect, as Node do not understand Cygwin directory tree, but works relatively well with relative names.

这远非完美,因为 Node 不理解 Cygwin 目录树,但在使用相对名称时效果相对较好。

回答by xjlin0

With Bj?rn's suggestion (using Console2) and Soyuka's alias (steps here), my node.js v0.10.13 and npm v1.3.2 are now working under Babunv1.02, a Cygwin distribution. enter image description here

根据 Bj?rn 的建议(使用 Console2)和 Soyuka 的别名(步骤在这里),我的 node.js v0.10.13 和 npm v1.3.2 现在可以在Cygwin 发行版Babun v1.02下工作。 在此处输入图片说明

回答by Destiny Architect

From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on thisanswer on thiseffectively-same question asked 1.5 years later.

在Windows中,运行Cygwin.bat(而不是Cygwin的终端),然后在运行节点:看到并回复上回答这个有效,同样的问题问1.5年后。

回答by mihai

Grab and run the node.js Windows installer.
In the Cygwin prompt type node
See if it works.

抓取并运行 node.js Windows 安装程序。
在 Cygwin 提示符下键入node
查看它是否有效。