File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -523,6 +523,49 @@ package.json是描述项目文件,描述项目所依赖的模块,当我们
523523
524524devDependencies下列出的模块,是我们开发时用的,比如grunt-contrib-uglify,我们用它混淆js文件,它们不会被部署到生产环境。dependencies下的模块,则是我们生产环境中需要的依赖。
525525
526+ npm发布模块:
527+
528+ 如果需要向npm发布自己的模块,那么需要注册账号密码,终端运行:
529+
530+ ```
531+ $npm adduser
532+ ```
533+ 按照提示填写账号密码邮箱,新建项目,配置package.json文件:
534+
535+ ```
536+ {
537+ "name": "hellonpm",
538+ "description": "hello world test app",
539+ "version": "0.0.1",
540+ "private": false,
541+ "dependencies": {
542+ "express": "2.5.9",
543+ "ejs":"0.4.2",
544+ "superagent":"0.3.0"
545+ }
546+ }
547+ ```
548+ name即为我们的模块名称,要注意的是private必须设置为false,模块才能被发布,dependencies是指我们的模块需要依赖哪些其他的模块,cd到express文件夹下:
549+
550+ ![ Mou icon] ( ./images/npm.jpg )
551+
552+ 终端运行:
553+
554+ ```
555+ $npm publish
556+ ```
557+
558+ ![ Mou icon] ( ./images/npm2.jpg )
559+
560+ 模块发布成功!
561+
562+ cd到任意文件夹运行:
563+
564+ ```
565+ $npm install hellonpm
566+ ```
567+ 即可安装我们上传的hellonpm模块!
568+
526569
527570
528571## 阅读文档
You can’t perform that action at this time.
0 commit comments