我应该建立节点。来自源的js还是下载OS X安装程序?

时间:2022-05-03 06:31:20

I'd like to install Node.js on OS X.

我想安装Node。js在OS X。

You can build it from source by cloning the Github repo, or you can download an installer.

您可以通过克隆Github repo从源代码构建它,也可以下载安装程序。

For those who've done Node.js development on OS X, what are the tradeoffs and which option would you recommend?

对于那些做过Node的人。在OS X上开发js,有什么取舍,你会推荐哪一种?

3 个解决方案

#1


2  

I would suggest not using the installer, or installing it via homebrew, instead use NVM to install whatever version of Node you need. That way you are able to fluidly develop in whatever version of node you choose, without having to worry about the headache of conflicting global packages or $PATH cruft.

我建议不要使用安装程序,或者通过homebrew安装它,而是使用NVM来安装您需要的任何版本的节点。这样,您就可以在选择的任何版本的节点中流畅地开发,而不必担心全局包冲突或$PATH cruft带来的麻烦。

#2


1  

I use the nodejs installer on osx. I see no benefit to building from source unless you actually want to mess with the source. You'll be up and running faster with the installer. They're keeping the binary installer up to date with the respect to the version too so it's not like you can get a later version by building from source.

我在osx上使用nodejs安装程序。我认为从源代码构建没有任何好处,除非您真的想破坏源代码。安装程序将使您运行得更快。他们将二进制安装程序和版本保持同步,所以你不可能从源代码中获得一个后续版本。

If you're deploying on some other platform, be careful about installing other binary packages using npm because they might not be available or might have to be rebuilt. I have sometimes made the mistake of copying node_modules binaries from OSX to Windows and of course they don't work. You have to run npm on Windows to get the right binaries for Windows and with complex things like phantomjs you can run into trouble...

如果您正在其他平台上部署,请小心使用npm安装其他二进制包,因为它们可能不可用,或者必须重新构建。我有时会犯这样的错误:将node_modules二进制文件从OSX复制到Windows,当然它们不能工作。你必须在Windows上运行npm才能得到Windows的正确二进制文件,还有像phantomjs这样复杂的东西,你可能会遇到麻烦……

#3


1  

Unless your production environment is OS X, I highly recommend just running a VM that is the same as your production environment.

除非您的生产环境是OS X,否则我强烈建议您只运行与您的生产环境相同的VM。

If you've ever built a non-trivial application in c, you know that cross-platform development is difficult. Different compilers can create different instructions for different architectures and operating systems. This variability can lead to bugs. You should aim to use the same source, same compiler, same operating system, same node.js version and same architecture as your production environment.

如果您曾经在c中构建过一个非平凡的应用程序,那么您就知道跨平台开发是很困难的。不同的编译器可以为不同的架构和操作系统创建不同的指令。这种变化会导致错误。您应该致力于使用相同的源、相同的编译器、相同的操作系统、相同的节点。js版本和与生产环境相同的体系结构。

Running your own VM as your dev environment will save you a tonne of time on integration issues (especially if there are other developers) and it will encourage you to write a single build script. Again, a critical time saver.

在开发环境中运行自己的VM将为您节省大量的集成问题(特别是如果有其他开发人员的话)时间,并鼓励您编写一个构建脚本。这又是一个关键的节省时间的方法。

Key points:

重点:

  • Single build command
  • 单一的构建命令
  • Mirror dev environments to production (reducing differences from compilers, architectures, source versions, etc.)
  • 镜像开发环境到生产环境(减少与编译器、体系结构、源版本等的差异)
  • Homogenize individual developers dev environments to ease testing and reduce bugs
  • 将单个开发人员开发环境均化,以简化测试并减少bug

#1


2  

I would suggest not using the installer, or installing it via homebrew, instead use NVM to install whatever version of Node you need. That way you are able to fluidly develop in whatever version of node you choose, without having to worry about the headache of conflicting global packages or $PATH cruft.

我建议不要使用安装程序,或者通过homebrew安装它,而是使用NVM来安装您需要的任何版本的节点。这样,您就可以在选择的任何版本的节点中流畅地开发,而不必担心全局包冲突或$PATH cruft带来的麻烦。

#2


1  

I use the nodejs installer on osx. I see no benefit to building from source unless you actually want to mess with the source. You'll be up and running faster with the installer. They're keeping the binary installer up to date with the respect to the version too so it's not like you can get a later version by building from source.

我在osx上使用nodejs安装程序。我认为从源代码构建没有任何好处,除非您真的想破坏源代码。安装程序将使您运行得更快。他们将二进制安装程序和版本保持同步,所以你不可能从源代码中获得一个后续版本。

If you're deploying on some other platform, be careful about installing other binary packages using npm because they might not be available or might have to be rebuilt. I have sometimes made the mistake of copying node_modules binaries from OSX to Windows and of course they don't work. You have to run npm on Windows to get the right binaries for Windows and with complex things like phantomjs you can run into trouble...

如果您正在其他平台上部署,请小心使用npm安装其他二进制包,因为它们可能不可用,或者必须重新构建。我有时会犯这样的错误:将node_modules二进制文件从OSX复制到Windows,当然它们不能工作。你必须在Windows上运行npm才能得到Windows的正确二进制文件,还有像phantomjs这样复杂的东西,你可能会遇到麻烦……

#3


1  

Unless your production environment is OS X, I highly recommend just running a VM that is the same as your production environment.

除非您的生产环境是OS X,否则我强烈建议您只运行与您的生产环境相同的VM。

If you've ever built a non-trivial application in c, you know that cross-platform development is difficult. Different compilers can create different instructions for different architectures and operating systems. This variability can lead to bugs. You should aim to use the same source, same compiler, same operating system, same node.js version and same architecture as your production environment.

如果您曾经在c中构建过一个非平凡的应用程序,那么您就知道跨平台开发是很困难的。不同的编译器可以为不同的架构和操作系统创建不同的指令。这种变化会导致错误。您应该致力于使用相同的源、相同的编译器、相同的操作系统、相同的节点。js版本和与生产环境相同的体系结构。

Running your own VM as your dev environment will save you a tonne of time on integration issues (especially if there are other developers) and it will encourage you to write a single build script. Again, a critical time saver.

在开发环境中运行自己的VM将为您节省大量的集成问题(特别是如果有其他开发人员的话)时间,并鼓励您编写一个构建脚本。这又是一个关键的节省时间的方法。

Key points:

重点:

  • Single build command
  • 单一的构建命令
  • Mirror dev environments to production (reducing differences from compilers, architectures, source versions, etc.)
  • 镜像开发环境到生产环境(减少与编译器、体系结构、源版本等的差异)
  • Homogenize individual developers dev environments to ease testing and reduce bugs
  • 将单个开发人员开发环境均化,以简化测试并减少bug