随笔- 191
文章- 0
评论- 3
阅读-
59242
随笔分类 - frontend / JavaScript / nodejs
nodejs + ts + nodemon + webpack 代码热更新
摘要:依赖: npm i nodemon webpack webpack-cli ts-loader typescript // webpack.config.js import { default as webpack } from "webpack"; import nodeExternals fro
阅读全文
nodejs websocket
摘要:github: 库地址 node后端: interface msgType { from: string; to: string; msg: string; } export class Server { private ws = require("nodejs-websocket"); priva
阅读全文
nodejs mkdirs
摘要:import path from "path"; import fs from "fs"; //注意所传路径必须是目录 const mkdirs = (location) => { if (fs.existsSync(location)) return; mkdirs(path.dirname(lo
阅读全文
nodejs 实现 AMD 加载 依赖
摘要:import fs from "fs"; import path from "path"; import vm from "vm"; export class LoadComponent { componentsPath: string = path.resolve("../first/compon
阅读全文
nodejs 组件引入
摘要:const fs = require("fs"); const nodePath = require("path"); // import * as fs from "fs"; const folder = "./"; const condition = ["node_modules", "comp
阅读全文
nodejs require 模块化模拟
摘要:require伪代码: // import fs from "fs"; var cache = {}; function require(modulePath) { //1.根据传入的模块路径获取绝对路径 用绝对路径作为id var moduleId = getModuleId(modulePath
阅读全文
nodejs 删除文件夹
摘要:const fs = require("fs"); const delDir = (dir) => { if (!fs.existsSync(dir)) { throw new Error("dir does not exist!"); } const list = fs.readdirSync(d
阅读全文
nodejs "Client does not support authentication protocol requested by server; consider upgrading MySQL client"
摘要:登录mysql输入以下命令: -- 选择mysql数据库:use mysql-- laremehpe是登录用户名ALTER USER 'laremehpe'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;-- laremehpe
阅读全文
nodejs从命令行获取参数
摘要://添加参数 let arr = process.argv; const config = { src: "",//添加参数 }; for (let i = 2, len = arr.length; i < len; i += 2) config[arr[i].substring(1)] = arr
阅读全文
uniapp 跨域设置cookie (后端nodejs)
摘要:首先关于request设置cookie需要先看uniapp官网的介绍:(h5端无法通过前端设置、修改cookie) 其次设置请求头具体没有说明要求,应该是按照标准来的 代码:nodejs模拟后端(因为本地测试用两个不同的端口,需要跨域): var ex = require('express') va
阅读全文
nodejs提取文件
摘要:const fs = require("fs"); //node extract.js -src "D:\桌面\tmp" -dest "D:\桌面\project\backup\A-28\public" let src = ""; let dest = null; let config = { fr
阅读全文
nodejs批量重命名
摘要:const fs = require("fs"); // directory path let config = { affix: null, src: null, from: 0, }; const resultList = []; let arr = process.argv; for (let
阅读全文
nodejs 遍历文件夹下所有文件
摘要:import fs from "fs"; import path from "path"; const find = ( folder: string, keyword: string[], callback: (val: string[]) => void ) => { type entryUni
阅读全文