如何在nodejs中初始化init

这篇文章将为大家详细讲解有关如何在nodejs中初始化init,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

打开cmd创建即可

$ npm init 
Package name: (hello) //模块名字,npm init会自动取当前目录名作为默认名字,这里不需要改,直接确认即可 
Description: A example for write a module //模块说明 
Package version: (0.0.0) 0.0.1 //模块版本号,这个大家按自己习惯来定就可以 
Project homepage: (none) //模块的主页,如果有的话可以填在这里,也可以不填 
Project git repository: (none) //模块的git仓库,选填。npm的用户一般都使用github做为自己的git仓库 
Author name: Elmer Zhang //模块作者名字 
Author email: (none) freeboy6716@gmail.com //模块作者邮箱 
Author url: (none) http://www.elmerzhang.com //模块作者URL 
Main module/entry point: (none) hello.js //模块的入口文件,我们这里是hello.js </span><span >(这个必填)</span><span > 
Test command: (none) //测试脚本,选填 
What versions of node does it run on? (~v0.5.7) * //依赖的node版本号,我们这个脚本可以运行在任何版本的node上,因此填 * 
About to write to /home/elmer/hello/package.json 
// 以下是生成的package.json文件内容预览 
{ 
 "author": "Elmer Zhang <freeboy6716@gmail.com> (http://www.elmerzhang.com)", 
 "name": "hello", 
 "description": "A example for write a module", 
 "version": "0.0.1", 
 "repository": { 
 "url": "" 
 }, 
 "main": "hello.js", 
 "engines": { 
 "node": "*" 
 }, 
 "dependencies": {}, 
 "devDependencies": {} 
} 
 
Is this ok? (yes) //对以上内容确认无误后,就可以直接回车确认了

关于如何在nodejs中初始化init就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。