简体   繁体   English

Node.js 不支持 Cygwin

[英]Node.js Cygwin not supported

I am trying to install node.js. I followed this tutorial and i am stuck in the middle.我正在尝试安装 node.js。我遵循了本教程,但我被困在中间。

When I write ./configure in my cygwin terminal it says "cygwin not supported".当我在我的 cygwin 终端中写./configure时,它说“不支持 cygwin”。 Please help me out Thanks in advance.请帮助我提前谢谢。

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.根据我的经验,Node 在 cygwin 中运行良好,Node 通常有 EINVAL 错误似乎是 MINTTY,它是 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.我仍然不确定为什么这些 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.此时运行文件和大多数 npm 包将在 MINTTY 中运行得很好,尽管每隔一段时间你会遇到某些 npm 包的 EINVAL 问题作为业力。 Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:此外,您将无法直接在 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.这将打开本机 cygwin bash.exe window,从这里运行解释器或任何导致 EINVAL 的麻烦 package 命令。 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.你必须这样做有点糟糕,但我很少每天使用它,而且我太喜欢 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')"

As a simpler derivative of troy's answer for those just looking to install NPM packages:对于那些只想安装 NPM 软件包的人来说,作为 troy 答案的更简单派生:

  1. Install Node.js with the Windows installer package.使用 Windows 安装程序package安装 Node.js。
  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).使用export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"将其添加到 PATH(显然用您安装它的位置替换 Node.js 安装目录的路径)。
  3. There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm . Windows 版本中存在当前错误,可以通过运行mkdir -p ~/AppData/Roaming/npm修复。 This is a bug for all of Windows and not just Cygwin.这是所有 Windows 而不仅仅是 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 .例如, 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.为了能够运行新安装的软件,您需要将安装位置添加到您的 PATH 中。 You can find these with npm bin -g and npm bin (the -g flag is the "global" installation location).您可以使用npm bin -gnpm 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 中运行,您不需要做任何特别的事情(尽管我不能说是否一切正常)。

Use Console2, it allows you to run create tabs of CLI shells.使用 Console2,它允许您运行 CLI shell 的创建选项卡。 It seems running cygwin inside console2 allows me to use node REPL just fine.似乎在 console2 中运行 cygwin 允许我很好地使用节点 REPL。 I have no idea why:P我不知道为什么:P

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

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 Babun v1.02, a Cygwin distribution.根据 Bjørn 的建议( 使用 Console2 )和 Soyuka 的别名(步骤 here ),我的 node.js v0.10.13 和 npm v1.3.2 现在可以在 Cygwin 发行版Babun v1.02 下运行。在此处输入图像描述

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,这样你就可以让bash直接与cmd控制台一起工作,可以完美支持所有节点工作。

C:\Users\郷>bash

郷@CHIGIX ~
$ node
>

I'm using this wrapper in /usr/local/bin/node (note no extension!)我在/usr/local/bin/node中使用这个包装器(注意没有扩展名!)

#!/bin/sh

_cmd="$(cygpath -lw -- "$1" )"
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 目录树,但使用相对名称时效果相对较好。

From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on this answer on this effectively-same question asked 1.5 years later.从 Windows 开始,运行 Cygwin.bat(而不是 Cygwin 终端),然后在该运行节点中:查看并回复 1.5 年后提出的这个有效相同问题的答案

Grab and run the node.js Windows installer.获取并运行 node.js Windows 安装程序。
In the Cygwin prompt type node在 Cygwin 提示符下键入node
See if it works.看看它是否有效。

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

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