10

As I understand it, there are two ways to install Express.js.

  1. Using npm install express - either from package.json or via command line. This method will install express locally in your node_modules folder.
  2. Using npm install express -g . This method installs the package globally on your machine.

I was just wondering what the benefits were to using either method. Is either one considered "best practice" over the other?

4

1 回答 1

16

要创建应用程序,您应该始终在本地安装它。这将允许您为您制作的每个应用程序使用不同的 express 版本。

全局安装 express 将允许您使用express命令行实用程序来创建样板代码和东西。所以理想情况下,你应该在两个地方都安装 express,但要确保你开发的应用程序在本地版本上运行。

于 2013-02-10T19:49:36.150 回答