2

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

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

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

4

3 回答 3

2

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

于 2013-08-09T20:12:55.633 回答
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.

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...

于 2013-08-09T20:09:28.817 回答
1

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

如果您曾经用 c 构建过一个重要的应用程序,那么您就会知道跨平台开发很困难。不同的编译器可以为不同的架构和操作系统创建不同的指令。这种可变性可能会导致错误。您的目标应该是使用与生产环境相同的源代码、相同的编译器、相同的操作系统、相同的 node.js 版本和相同的架构。

运行你自己的虚拟机作为你的开发环境将节省你大量的时间在集成问题上(特别是如果有其他开发人员),它会鼓励你编写一个单独的构建脚本。再次,一个关键的节省时间。

关键点:

  • 单个构建命令
  • 将开发环境镜像到生产环境(减少编译器、架构、源版本等的差异)
  • 同质化单个开发人员的开发环境以简化测试并减少错误
于 2013-08-09T20:04:18.370 回答