# NodeJS
# Flag
node
执行脚本时获取参数process.argv
数组,下标0
为执行程序的绝对路径,下标1
为脚本的绝对路径, 所以真正的参数从下标2
开始process.argv.splice(2)
- 纯JavaScript实现 https://github.com/jsdom/jsdom (opens new window)
- https://github.com/stylus (opens new window)
- https://github.com/webpack/webpack (opens new window)
- https://github.com/sveltejs/svelte (opens new window)
- 2009年,npm
- 2012年,grunt
- 2012年,bower
- 2013年,yeoman
- 2014年,gulp
- 2015年,fis3
- 2017年,webpack3
# 第三方库
- https://github.com/isaacs/minimatch (opens new window)
- https://github.com/mrmlnc/fast-glob (opens new window)
# 管理NodeJS
- https://github.com/tj/n (opens new window)
- https://github.com/Jrohy/nodejs-install (opens new window)
rpm
npm与Node.js一起存在,这意味着当您下载并安装Node.js时,您会自动在计算机上安装npm
# CentOS安装
# 到https://github.com/nodesource/distributions#installation-instructions-1
# 复制更新软件源命令,并执行
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
# 安装
yum install -y nodejs
# 检查Node.js和NPM版本
node -v && npm -v
NVM
nodeJs版本管理工具,管理nodejs版本和npm版本
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
# 刷新
source ~/.bashrc
# 查询最新版本号
nvm ls-remote --lts
# 安装稳定版 Nodejs
nvm install <最新的版本号>
# 依赖管理
- https://github.com/Unitech/pm2 (opens new window)
- https://github.com/npm (opens new window)
- https://github.com/yarnpkg (opens new window)
# 管理yarn
# 安装
npm install -g yarn
卸载
# 查找目录并删除
yarn global bin
# 卸载
npm uninstall -g yarn
# 依赖镜像
npm i -g nrm
安装nrm
,nrm ls
查看下载镜像源,nrm use taobao
切换镜像源
手动配置
如果使用
yarn
,就把命令开头的npm
替换为yarn
# 查看仓库地址
npm config get registry
# 设置官方仓库地址
npm config set registry https://registry.npmjs.org
# 设置淘宝镜像仓库地址
npm config set registry https://registry.npm.taobao.org
# 查看代理地址
npm config get proxy
npm config get https-proxy
# 设置代理地址
npm config set proxy http://127.0.0.1:1080
# 设置https代理地址
npm config set https-proxy http://server:port
# 设置代理用户名和密码
npm config set proxy http://username:password@server:port
npm confit set https-proxy http://username:password@server:port
# 删除代理地址
npm config delete proxy
npm config delete https-proxy
# 更新依赖包
yarn
yarn.lock
和package.json
都会更新,但是会进行版本锁定
- 更新所有到最新版本
需要手动选择升级的依赖包,a键选择所有,i键反向选择
yarn upgrade-interactive --latest
- 更新单个到指定版本
yarn upgrade package@latest
npm
更新
dependencies
到最新版本
# 先检查更新
npm outdated
# 安装
npm install -g npm-check-updates
# 检查可更新依赖,ncu
npm-check-updates
# 更新,ncu -u
ncu --upgrade
# 安装最新版本依赖
npm install
# yarn和npm命令
npm | yarn | 说明 |
---|---|---|
npm install(i) | yarn/yarn install | 根据package.json安装依赖 |
npm uninstall(un) 包名 –-global(-g) | yarn global remove 包名 | 卸载全局依赖包 |
npm uninstall(un) 包名 -–save(-S) | yarn remove 包名 | 卸载依赖,并删除package.json中的 |
npm uninstall(un) 包名 -–save-dev(-D) | yarn remove 包名 –dev(-D) | 卸载开发环境依赖 |
npm install 包名 –-global(-g) | yarn global add 包名 | 安装全局依赖包 |
npm install 包名 -–save(-S) | yarn add 包名 | 安装依赖,并保存到package.json |
npm install 包名 -–save-dev(-D) | yarn add 包名 –dev(-D) | 安装开发环境依赖 |
npm update 包名 –-global(-g) | yarn global upgrade 包名 | 更新全局依赖 |
npm update 包名 -–save(-S) | yarn upgrade 包名 | 更新依赖 |
npm update 包名 -–save-dev(-D) | yarn upgrade 包名 –dev(-D) | 更新开发环境依赖 |
npm cache clean | yarn cache clean | 清除缓存 |
rm -rf node_modules && npm install | yarn upgrade | 重装 |
npm init | yarn init | 初始化某个项目 |
npm publish/login/logout | yarn publish/login/logout | 发布/登录/登出,NPM Registry操作 |
npm run/test 命令 | yarn run/test 命令 | 运行某个命令 |
# 解析
/**
* https://www.npmjs.com/search?q=keywords:xml2js
*/
const fs = require("fs");
//模拟发送http请求
const request = require("request");
// npm install xpath
// https://github.com/yaronn/xpath.js
const xpath = require('xpath');
//get请求
request('https://jolx-1256021553.cos.ap-chengdu.myqcloud.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
// npm install xmlreader
// const xmlreader = require("xmlreader");
// xmlreader.read(body, function (errors, res) {
// if (null !== errors) {
// console.log(errors)
// return;
// }
// console.log(res);
// });
// npm install xml2js
// const Xml2js = require('xml2js');
// const Parser = new Xml2js.Parser({ explicitArray: false, ignoreAttrs: false });
// Parser.parseString(body, function (err, result) {
// console.log(result);
// });
// npm install xmldom
// https://github.com/goto100/xpath
// const dom = require('xmldom').DOMParser;
// let doc = new dom().parseFromString(body);
// console.log(doc);
// npm install fast-xml-parser
// const parser = require('fast-xml-parser');
// const doc = parser.parse(body);
// console.log(doc);
// npm install xml-js
const convert = require('xml-js');
const doc = convert.xml2js(body);
console.log(doc);
}
});
//post请求
request({
url: "https://jolx-1256021553.cos.ap-chengdu.myqcloud.com",
method: "post",//如果是post就涉及到跨域的问题了
json: true,
headers: {
"content-type": "application/json",
},
body: {
account: 'admin',
pwd: 'admin'
}
}, function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
}
});
# 原生桌面应用
- https://github.com/topics/electron (opens new window)
- 使用 node-ffi 构建 Electron 和 C++ Library 混合桌面应用 (opens new window)
- https://github.com/topics/nwjs (opens new window)
- https://github.com/Kagami/mpv.js (opens new window)
- https://github.com/apache/cordova (opens new window)
- 将 Node.js 项目打包到可执行文件中 https://github.com/vercel/pkg (opens new window)
- https://github.com/facebook/react-native (opens new window)
# 爬虫
- https://github.com/webdriverio (opens new window)
- https://github.com/puppeteer (opens new window)
- Puppeteer配置小记 (opens new window)
- https://github.com/microsoft/playwright (opens new window)
- 一个基于webkit的JavaScript API https://github.com/ariya/phantomjs (opens new window)
- https://github.com/ebidel/try-puppeteer (opens new window)
- https://github.com/berstend/puppeteer-extra (opens new window)
- Expect交互 https://github.com/facebook/jest (opens new window)
- https://github.com/sinonjs (opens new window)
- https://github.com/chaijs (opens new window)
# 小程序
- https://github.com/search?q=weapp (opens new window)
- https://github.com/topics/wxapp (opens new window)
- https://github.com/topics/weapp (opens new window)
- https://github.com/topics/wechat (opens new window)
- https://github.com/topics/minapp (opens new window)
- https://github.com/topics/wechat-app (opens new window)
- https://github.com/topics/wechat-mini-program (opens new window)
- https://github.com/topics/weixin (opens new window)
- https://github.com/justjavac/awesome-wechat-weapp (opens new window)
- https://github.com/qiushi123/xiaochengxu_demos (opens new window)
- 使用Golang开发的微信SDK: https://github.com/silenceper/wechat (opens new window)
框架
- https://github.com/dcloudio/uni-app (opens new window)
- https://github.com/NervJS/taro (opens new window)
- https://github.com/tinajs/tina (opens new window)
- https://github.com/didi/chameleon (opens new window)
- https://github.com/didi/mpx (opens new window)
- https://github.com/kaola-fed/megalo (opens new window)
- https://github.com/Tencent/wepy (opens new window)
- https://github.com/Meituan-Dianping/mpvue (opens new window)
Other
- https://gitee.com/laeser/demo-weapp (opens new window)
- 小程序海报组件-生成朋友圈分享海报并生成图片 (opens new window)
- 微信小程序Markdown渲染库 (opens new window)
- 手持弹幕微信小程序版 (opens new window)
- https://github.com/super456/weapp_expressTime (opens new window)
- https://github.com/ecomfe/echarts-for-weixin (opens new window)
# 自定义组件
组件库
- https://github.com/youzan/vant-weapp (opens new window)
- https://github.com/jisida/VtuWeapp (opens new window)
- https://github.com/wux-weapp/wux-weapp (opens new window)
- https://github.com/Tencent/weui (opens new window)
- https://github.com/weilanwl/ColorUI (opens new window)
日历
授权
- https://github.com/misterxu1567/wxMiniProgram-components (opens new window)
- https://github.com/GRW999/auth-component (opens new window)
- https://github.com/yeyi361936738/mini-login-component (opens new window)
- https://github.com/Skura23/authModal (opens new window)
搜索