Article directory
1. Have an npm account
Address: https://www.npmjs.com/
may be slow, be patient.
2, the command line login
a) Taobao mirrors should be deleted.
b) npm login input information.
3, related to making wheels
js requirements
lib library:
feel free to export what you need.
Executables:
have a fixed beginning:
#!/usr/bin/env node
Otherwise it will not work properly.
package.json
Take my wheel as an example:
name: npm package name, longer to prevent repetition.
version: increment by 1 each time. Unable to remove old versions.
author: myself.
license: open source license, if you play by yourself, you don't need to pay special attention.
dependencies: dependencies.
files: All files included. will appear in the final package.
bin: Console assembly. The key is the instruction, and the value is the corresponding js file.
{
"name": "get_bing_image",
"version": "1.1.4",
"author": "zxing2021",
"license": "ISC",
"dependencies": {
"cheerio": "^1.0.0-rc.10",
"got": "^11.8.3"
},
"files": [
"./index.js"
],
"bin": {
"get_bing_image": "./index.js"
}
}
a few tips
Get the parameters of the command line execution: use the wheel commander.
Several paths:
process.cwd(): The path to execute.
__dirname: The directory where the js file is located.
process.env["xxx"]: specific environment variables.
readme.md
Put it under the root path and can appear on npm.
4. Command line release
Execute the release command:
npm publish
Extra: My Wheels
grabbing bing wallpaper
https://www.npmjs.com/package/get_bing_image
This is my first wheel.
Function: Grab the bing wallpaper to the local.
Install globally:
npm i get_bing_image -g
call command:
get_bing_image
Effect:
File upload and download server
https://www.npmjs.com/package/tiny_file_server
Role: build an express server, zero code, dedicated to file upload and download.
Install globally:
npm i tiny_file_server -g
call command:
tiny_file_server -p 8081 -f D:/
Effect: port 8081, the file will be saved in the root directory of the d drive.
There is also a page for testing the corresponding port.
Only a single upload for now.
Create project from zip
See this article for the article: https://blog.csdn.net/qq_37284843/article/details/124059268
Any project can be created on the fly. Unzip the zip file.
Similar to git clone, but locally.