Development of Npm package
Directory structure of personal development package ├── coverage / / istanbul test coverage generated file ├── index.js / / entry file ├── introduce.md / / description file ├── lib │ └── node-cnblogs-spider.js / / main file ├── node_modules / / third-party package ├── package.json ├── README.md └── test / / Unit test file └── node-cnblogs-spider.test.js development step registration
Npmjs
Add user on the command line
After the registration is successful, execute on the command line
Zqz@ubuntu:~$ npm adduserUsername:
Fill in and enter one by one.
Whoami
After filling in the above, enter on the command line
Zqz@ubuntu:~$ whoamizqz
It means it worked.
Npm publish
Finally, it is posted on npmjs
Npm publish
A similar version number appears below and it is a success.
+.... @ 1.0.0index.js / * Export node-cnblogs-spider * / exports = module.exports = require ('. / lib/node-cnblogs-spider'); / * Export the version*/exports.version = require ('. / package.json') .version; installation & using npm install node-cnblogs-spider-- savevar ncs = require ('node-cnblogs-spider'); ncs ([url1,url2....]) Problems that may be encountered. Npm cannot log in.
When you add adduser, you fill in the password, account number and email address correctly. But it's always wrong.
This may be the source of your npm modified to Taobao.
Version number
Be careful to change the version number in package.json each time you release it.
The version number cannot be the same each time it is released.
For example: this time it is 1.0.0, it must not be 1.0.0 next time, otherwise it will make a mistake.