We will write by some public methods, to use in the project, if it is to be a series of multiple projects when they would replicate copy as a developer in fact, we can add some of their own dependencies, and each time use when we installed our dependencies on it; npm package release:
1, npm init file to initialize package.json
npm init { "name": "npm-example-demo", "version": "1.0.0", "description": "npm-example", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "luotongzhou", "license": "ISC" } 如果是私有的包可以添加: "publishConfig": { "registry": "http://localhost/repository/npm-hosted/" }
2, create a file entry module
To create a directory entry file according to the file entry in the main file package.json
3, released npm package
If you do not npm account then we need to apply for a npm account, then configure your own name
adduser npm the Username: Enter the user name # Password: # Enter the password, not visible by default Email: # Enter the mailbox display # after the registration is completed Logged in as <your username> on http://registry.npmjs.org/.
Command is issued npm package npm publish
If you want to update, then npm package can modify the version number, and then perform npm version patch | minor | major to