如何编译/安装 node.js(无法配置 cxx 编译器!)(Ubuntu)。

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3329355/
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 13:39:12  来源:igfitidea点击:

How to compile/install node.js(could not configure a cxx compiler!) (Ubuntu).

linuxubuntucompilationinstallnode.js

提问by Alfred

How can I compile/install node.js on Ubuntu? It failed with an error about cxx compiler.

如何在 Ubuntu 上编译/安装 node.js?它失败并出现关于 的错误cxx compiler

回答by Alfred

One-linerto install all needed dependencies(curl and git are not really needed, but are very useful and also needed if you install via nvm).

一衬垫安装所有需要的依赖(卷曲和git并不真正需要的,但非常有用的,如果你安装通过NVM还需要)。

sudo apt-get install build-essential libssl-dev curl git-core

Last two dependencies are not always needed, but installing them is really usefull anyway and you probably need it later anyway.

最后两个依赖项并不总是需要的,但无论如何安装它们确实很有用,而且您以后可能需要它。

To only install cxx compiler

只安装cxx 编译器

sudo apt-get install build-essential

If opensslis missing

如果缺少openssl

sudo apt-get install libssl-dev

回答by Jay Sidri

If like me, you are attempting to install this on an AWS instance running Amazon Linux AMI (which looks to be a cut down version CentOS):

如果像我一样,您正在尝试将它安装在运行 Amazon Linux AMI 的 AWS 实例上(它看起来是一个精简版的 CentOS):

Install base tools:

安装基础工具:

yum groupinstall "Development Tools"

yum groupinstall "Development Tools"

Now install openssl-devel:

现在安装openssl-devel:

yum install openssl-devel

yum install openssl-devel

Node should compile fine now.

Node 现在应该可以正常编译了。

回答by Nicholas Blumhardt

If you're attempting this on Win7 like me, running:

如果您像我一样在 Win7 上尝试此操作,请运行:

ash.exe
$ /bin/rebaseall

...did the trick.

...成功了。

Good luck!

祝你好运!

回答by mjamal

If you find yourself getting this error on Mac OSX, you need to install XCode.

如果您发现自己在 Mac OSX 上遇到此错误,则需要安装 XCode。

https://developer.apple.com/

https://developer.apple.com/

回答by Kelstar

I needed to run yum install gcc-c++on Cent OS.

我需要yum install gcc-c++在 Cent OS 上运行。

回答by nolazybits

回答by Pax Beach

For Node.js v6:

对于 Node.js v6:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

For Node.js v7:

对于 Node.js v7:

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
sudo apt-get install -y nodejs

Optional: install build toolsTo compile and install native addons from npm you may also need to install build tools:

可选:安装构建工具要从 npm 编译和安装本机插件,您可能还需要安装构建工具:

sudo apt-get install -y build-essential

After to get latest NPM packages, if you need:

在获取最新的 NPM 包之后,如果您需要:

npn update -g

Partial source here.

部分来源在这里。