随笔- 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 阅读全文
posted @ 2024-04-10 15:45 laremehpe 阅读(97) 评论(0) 推荐(0) 编辑
nodejs websocket
摘要:github: 库地址 node后端: interface msgType { from: string; to: string; msg: string; } export class Server { private ws = require("nodejs-websocket"); priva 阅读全文
posted @ 2024-04-02 11:39 laremehpe 阅读(20) 评论(0) 推荐(0) 编辑
nodejs mkdirs
摘要:import path from "path"; import fs from "fs"; //注意所传路径必须是目录 const mkdirs = (location) => { if (fs.existsSync(location)) return; mkdirs(path.dirname(lo 阅读全文
posted @ 2024-03-29 13:56 laremehpe 阅读(17) 评论(0) 推荐(0) 编辑
nodejs 实现 AMD 加载 依赖
摘要:import fs from "fs"; import path from "path"; import vm from "vm"; export class LoadComponent { componentsPath: string = path.resolve("../first/compon 阅读全文
posted @ 2024-03-21 16:27 laremehpe 阅读(21) 评论(0) 推荐(0) 编辑
nodejs 组件引入
摘要:const fs = require("fs"); const nodePath = require("path"); // import * as fs from "fs"; const folder = "./"; const condition = ["node_modules", "comp 阅读全文
posted @ 2024-01-30 13:25 laremehpe 阅读(14) 评论(0) 推荐(0) 编辑
nodejs require 模块化模拟
摘要:require伪代码: // import fs from "fs"; var cache = {}; function require(modulePath) { //1.根据传入的模块路径获取绝对路径 用绝对路径作为id var moduleId = getModuleId(modulePath 阅读全文
posted @ 2023-12-24 00:45 laremehpe 阅读(25) 评论(0) 推荐(0) 编辑
nodejs 删除文件夹
摘要:const fs = require("fs"); const delDir = (dir) => { if (!fs.existsSync(dir)) { throw new Error("dir does not exist!"); } const list = fs.readdirSync(d 阅读全文
posted @ 2023-12-11 13:56 laremehpe 阅读(130) 评论(0) 推荐(0) 编辑
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 阅读全文
posted @ 2023-11-16 10:50 laremehpe 阅读(35) 评论(0) 推荐(0) 编辑
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 阅读全文
posted @ 2023-04-23 15:08 laremehpe 阅读(184) 评论(0) 推荐(0) 编辑
uniapp 跨域设置cookie (后端nodejs)
摘要:首先关于request设置cookie需要先看uniapp官网的介绍:(h5端无法通过前端设置、修改cookie) 其次设置请求头具体没有说明要求,应该是按照标准来的 代码:nodejs模拟后端(因为本地测试用两个不同的端口,需要跨域): var ex = require('express') va 阅读全文
posted @ 2023-03-17 00:29 laremehpe 阅读(2768) 评论(0) 推荐(0) 编辑
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 阅读全文
posted @ 2023-03-05 15:42 laremehpe 阅读(18) 评论(0) 推荐(0) 编辑
nodejs批量重命名
摘要:const fs = require("fs"); // directory path let config = { affix: null, src: null, from: 0, }; const resultList = []; let arr = process.argv; for (let 阅读全文
posted @ 2023-02-08 10:37 laremehpe 阅读(109) 评论(0) 推荐(0) 编辑
nodejs 遍历文件夹下所有文件
摘要:import fs from "fs"; import path from "path"; const find = ( folder: string, keyword: string[], callback: (val: string[]) => void ) => { type entryUni 阅读全文
posted @ 2022-11-12 11:10 laremehpe 阅读(266) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示