node.js-http, url module, npm publish


Use ES6 ex/import in node.js

If want to do ES6 ex/im manner, set “type” in package.json as “module”:

module and module.exports point to a same imported object

Http Modul

Simple Use:

Publish an NPM Package

1. Create a folder with 3 files: package.json, README.md, index.js:

2. Init package.json with 6 key-values:

  1. name should be unique
  2. main, the entry of the package
  3. search key words on npm

3. Write code, export exported part in index.js:

4. Publish package on NPM

1. Create NPM account

2. Login NPM account on the terminal using npm login

3. cd into the root directory of the package, execute npm publish

4. Can use npm unpublish to to unpublish package that has been published with in 24hour


A u t h o r: Joe
P o l i c y: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source Joe !
Leave Your Comment Here
  TOC