Installing
Assuming you’ve already installed Node.js, create a directory to hold your application, and make that your working directory.
$ mkdir myapp
$ cd myapp
Use the npm init command to create a package.json file for your application. For more information on how package.json works, see Specifics of npm’s package.json handling.
$ npm init
This command prompts you for a number of things, such as the name and version of your application. For now, you can simply hit RETURN to accept the defaults for most of them, with the following exception:
entry point: (index.js)
Enter app.js, or whatever you want the name of the main file to be. If you want it to be index.js, hit RETURN to accept the suggested default file name.
Now install Express in the myapp directory and save it in the dependencies list. For example:
$ npm install express --save
To install Express temporarily and not add it to the dependencies list, omit the --save option:
$ npm install express
Node modules installed with the --save option are added to the dependencies list in the package.json file. Afterwards, running npm install in the app directory will automatically install modules in the dependencies list.

本文介绍如何在已安装Node.js的环境中创建新的应用程序目录,并使用npminit命令生成package.json文件。此外还介绍了如何安装Express框架并将其添加到依赖项列表中。
774

被折叠的 条评论
为什么被折叠?



